diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-22 21:14:08 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-22 21:14:08 +0000 |
commit | b3fb872d9db31d752aeefdb62b7ea928b9cadc42 (patch) | |
tree | d9673fabbc7dc4dd00fc27a56f656174a3e5a05b /ext | |
parent | ec3056ae227fd79d706b2c6cdcdd8725df99c178 (diff) | |
download | ruby-b3fb872d9db31d752aeefdb62b7ea928b9cadc42.tar.gz |
* ext/psych/lib/psych/visitors/to_ruby.rb: Handle nil tags specially
to avoid slow method_missing calls. Thanks Kevin Menard!
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37289 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/psych/lib/psych/visitors/to_ruby.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb index 088301ac14..c6cf018888 100644 --- a/ext/psych/lib/psych/visitors/to_ruby.rb +++ b/ext/psych/lib/psych/visitors/to_ruby.rb @@ -118,6 +118,8 @@ module Psych 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 @@ module Psych 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 @@ module Psych 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 |