diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-02-21 17:42:50 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-02-21 17:42:50 +0000 |
commit | 846b8118df73b63026903db7a99a4b7222ce5b2c (patch) | |
tree | 30223923aaae70341d7b33a649c6b5edf630bc22 /ext | |
parent | 8b5a3b7d39a8768cb0e7cc082c0c84c7ead92155 (diff) | |
download | ruby-846b8118df73b63026903db7a99a4b7222ce5b2c.tar.gz |
* 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
Diffstat (limited to 'ext')
-rw-r--r-- | ext/psych/lib/psych/visitors/yaml_tree.rb | 9 |
1 files changed, 6 insertions, 3 deletions
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) |