1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/rexml/source.rb (REXML::SourceFactory::SourceFactory): more

duck typed.  better performance on JRuby.
  http://headius.blogspot.com/2007/10/another-performance-discovery-rexml.html

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2007-10-18 07:41:21 +00:00
parent fada885be6
commit b8c9921c02
2 changed files with 13 additions and 6 deletions

View file

@ -1,3 +1,9 @@
Thu Oct 18 16:39:34 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/rexml/source.rb (REXML::SourceFactory::SourceFactory): more
duck typed. better performance on JRuby.
http://headius.blogspot.com/2007/10/another-performance-discovery-rexml.html
Thu Oct 18 09:33:25 2007 Yukihiro Matsumoto <matz@ruby-lang.org> Thu Oct 18 09:33:25 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* range.c (range_first): takes first n element if argument is * range.c (range_first): takes first n element if argument is

View file

@ -7,13 +7,14 @@ module REXML
# @param arg Either a String, or an IO # @param arg Either a String, or an IO
# @return a Source, or nil if a bad argument was given # @return a Source, or nil if a bad argument was given
def SourceFactory::create_from(arg) def SourceFactory::create_from(arg)
if arg.kind_of? String if arg.respond_to? :read and
Source.new(arg) arg.respond_to? :readline and
elsif arg.respond_to? :read and arg.respond_to? :nil? and
arg.respond_to? :readline and arg.respond_to? :eof?
arg.respond_to? :nil? and
arg.respond_to? :eof?
IOSource.new(arg) IOSource.new(arg)
elsif arg.respond_to? :to_str
require 'stringio'
IOSource.new(StringIO.new(arg))
elsif arg.kind_of? Source elsif arg.kind_of? Source
arg arg
else else