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

ruby-changes:18908

From: tenderlove <ko1@a...>
Date: Tue, 22 Feb 2011 02:42:58 +0900 (JST)
Subject: [ruby-changes:18908] Ruby:r30933 (trunk): * ext/psych/lib/psych/visitors/yaml_tree.rb (accept): use Hash#key?

tenderlove	2011-02-22 02:42:50 +0900 (Tue, 22 Feb 2011)

  New Revision: 30933

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

  Log:
    * ext/psych/lib/psych/visitors/yaml_tree.rb (accept): use Hash#key?
      when looking up object references to err on the side of cache
      misses.

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

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 30932)
+++ ChangeLog	(revision 30933)
@@ -1,3 +1,9 @@
+Tue Feb 22 02:41:51 2011  Aaron Patterson <aaron@t...>
+
+	* ext/psych/lib/psych/visitors/yaml_tree.rb (accept): use Hash#key?
+	  when looking up object references to err on the side of cache
+	  misses.
+
 Mon Feb 21 10:58:39 2011  Aaron Patterson <aaron@t...>
 
 	* ext/psych/lib/psych/json/yaml_events.rb: refactoring JSON event
Index: ext/psych/lib/psych/visitors/yaml_tree.rb
===================================================================
--- ext/psych/lib/psych/visitors/yaml_tree.rb	(revision 30932)
+++ ext/psych/lib/psych/visitors/yaml_tree.rb	(revision 30933)
@@ -70,9 +70,12 @@
 
       def accept target
         # return any aliases we find
-        if node = @st[target.object_id]
-          node.anchor = target.object_id.to_s
-          return @emitter.alias target.object_id.to_s
+        if @st.key? target.object_id
+          oid         = target.object_id
+          node        = @st[oid]
+          anchor      = oid.to_s
+          node.anchor = oid
+          return @emitter.alias oid
         end
 
         if target.respond_to?(:to_yaml)

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

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