Skip to content

Commit

Permalink
Don't create extraneous blocks. Using the exploded if seems to be a b…
Browse files Browse the repository at this point in the history
…it faster than inlining it, as well.
  • Loading branch information
cheald authored and nex3 committed Nov 22, 2011
1 parent 848be1b commit 399de7f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/haml/compiler.rb 100644 → 100755
Expand Up @@ -443,8 +443,11 @@ def rstrip_buffer!(index = -1)

def compile(node)
parent, @node = @node, node
block = proc {node.children.each {|c| compile c}}
send("compile_#{node.type}", &(block unless node.children.empty?))
if node.children.empty?
send("compile_#{node.type}")
else
send("compile_#{node.type}", &proc {node.children.each {|c| compile c}} )
end
ensure
@node = parent
end
Expand Down

0 comments on commit 399de7f

Please sign in to comment.