diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-10-18 07:41:21 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-10-18 07:41:21 +0000 |
commit | 0142e0bcf460f0e9722418fedf782c1690838ed1 (patch) | |
tree | adf93a6dc649c4483bd137869bd88e135208081d /lib/rexml | |
parent | c100ab5cd97f31a278551e4c1242d80fd5add536 (diff) | |
download | ruby-0142e0bcf460f0e9722418fedf782c1690838ed1.tar.gz ruby-0142e0bcf460f0e9722418fedf782c1690838ed1.tar.xz ruby-0142e0bcf460f0e9722418fedf782c1690838ed1.zip |
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@13737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rexml')
-rw-r--r-- | lib/rexml/source.rb | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/rexml/source.rb b/lib/rexml/source.rb index bc99c0ed6..659bcdc19 100644 --- a/lib/rexml/source.rb +++ b/lib/rexml/source.rb @@ -7,13 +7,14 @@ module REXML # @param arg Either a String, or an IO # @return a Source, or nil if a bad argument was given def SourceFactory::create_from(arg) - if arg.kind_of? String - Source.new(arg) - elsif arg.respond_to? :read and - arg.respond_to? :readline and - arg.respond_to? :nil? and - arg.respond_to? :eof? + if arg.respond_to? :read and + arg.respond_to? :readline and + arg.respond_to? :nil? and + arg.respond_to? :eof? IOSource.new(arg) + elsif arg.respond_to? :to_str + require 'stringio' + IOSource.new(StringIO.new(arg)) elsif arg.kind_of? Source arg else |