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

ruby-changes:25237

From: tenderlove <ko1@a...>
Date: Tue, 23 Oct 2012 06:14:22 +0900 (JST)
Subject: [ruby-changes:25237] tenderlove:r37289 (trunk): * ext/psych/lib/psych/visitors/to_ruby.rb: Handle nil tags specially

tenderlove	2012-10-23 06:14:08 +0900 (Tue, 23 Oct 2012)

  New Revision: 37289

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37289

  Log:
    * ext/psych/lib/psych/visitors/to_ruby.rb: Handle nil tags specially
      to avoid slow method_missing calls.  Thanks Kevin Menard!

  Modified files:
    trunk/ChangeLog
    trunk/ext/psych/lib/psych/visitors/to_ruby.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 37288)
+++ ChangeLog	(revision 37289)
@@ -1,3 +1,8 @@
+Tue Oct 23 06:12:39 2012  Aaron Patterson <aaron@t...>
+
+	* ext/psych/lib/psych/visitors/to_ruby.rb: Handle nil tags specially
+	  to avoid slow method_missing calls.  Thanks Kevin Menard!
+
 Tue Oct 23 06:07:57 2012  Aaron Patterson <aaron@t...>
 
 	* ext/psych/lib/psych/scalar_scanner.rb: Ignore bad timestamps.  If
Index: ext/psych/lib/psych/visitors/to_ruby.rb
===================================================================
--- ext/psych/lib/psych/visitors/to_ruby.rb	(revision 37288)
+++ ext/psych/lib/psych/visitors/to_ruby.rb	(revision 37289)
@@ -118,6 +118,8 @@
         end
 
         case o.tag
+        when nil
+          register_empty(o)
         when '!omap', 'tag:yaml.org,2002:omap'
           map = register(o, Psych::Omap.new)
           o.children.each { |a|
@@ -130,9 +132,7 @@
           o.children.each { |c| list.push accept c }
           list
         else
-          list = register(o, [])
-          o.children.each { |c| list.push accept c }
-          list
+          register_empty(o)
         end
       end
 
@@ -252,6 +252,12 @@
         object
       end
 
+      def register_empty object
+        list = register(object, [])
+        object.children.each { |c| list.push accept c }
+        list
+      end
+
       def revive_hash hash, o
         @st[o.anchor] = hash if o.anchor
 

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

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