Permalink
Browse files

Merge pull request #88 from nirvdrum/reduce_method_missing

Handle nil tags specially to avoid slow method_missing calls.
  • Loading branch information...
2 parents 08da2c2 + 85a1ae2 commit 465ae0ad16231462e55134a864f5816305114b97 @tenderlove tenderlove committed Oct 1, 2012
Showing with 9 additions and 3 deletions.
  1. +9 −3 lib/psych/visitors/to_ruby.rb
@@ -118,6 +118,8 @@ def visit_Psych_Nodes_Sequence o
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 @@ def visit_Psych_Nodes_Sequence o
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 @@ def register node, object
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

0 comments on commit 465ae0a

Please sign in to comment.