From 846b8118df73b63026903db7a99a4b7222ce5b2c Mon Sep 17 00:00:00 2001 From: tenderlove Date: Mon, 21 Feb 2011 17:42:50 +0000 Subject: [PATCH] * 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30933 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ ext/psych/lib/psych/visitors/yaml_tree.rb | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4b46411ea8..9040b6e05b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Feb 22 02:41:51 2011 Aaron Patterson + + * 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 * ext/psych/lib/psych/json/yaml_events.rb: refactoring JSON event diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb index e7d182f707..6d6f96ea32 100644 --- a/ext/psych/lib/psych/visitors/yaml_tree.rb +++ b/ext/psych/lib/psych/visitors/yaml_tree.rb @@ -70,9 +70,12 @@ module Psych 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)