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)