[前][次][番号順一覧][スレッド一覧]

ruby-changes:2246

From: ko1@a...
Date: 18 Oct 2007 16:41:34 +0900
Subject: [ruby-changes:2246] matz - Ruby:r13737 (trunk): * lib/rexml/source.rb (REXML::SourceFactory::SourceFactory): more

matz	2007-10-18 16:41:21 +0900 (Thu, 18 Oct 2007)

  New Revision: 13737

  Modified files:
    trunk/ChangeLog
    trunk/lib/rexml/source.rb

  Log:
    * 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

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13737&r2=13736
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rexml/source.rb?r1=13737&r2=13736

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 13736)
+++ ChangeLog	(revision 13737)
@@ -1,3 +1,9 @@
+Thu Oct 18 16:39:34 2007  Yukihiro Matsumoto  <matz@r...>
+
+	* 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@r...>
 
 	* range.c (range_first): takes first n element if argument is
Index: lib/rexml/source.rb
===================================================================
--- lib/rexml/source.rb	(revision 13736)
+++ lib/rexml/source.rb	(revision 13737)
@@ -7,13 +7,14 @@
     # @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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧]