Avoid keeping track of two lists of nodes during parsing.

This commit is contained in:
Dylan Thacker-Smith
2014-03-25 16:16:38 -04:00
parent c0832ce0d1
commit 8e45b44b21
+2 -7
View File
@@ -14,9 +14,6 @@ module Liquid
@nodelist ||= [] @nodelist ||= []
@nodelist.clear @nodelist.clear
# All child tags of the current block.
@children = []
while token = tokens.shift while token = tokens.shift
case token case token
when IsTag when IsTag
@@ -31,7 +28,6 @@ module Liquid
new_tag = tag.parse($1, $2, tokens, @options) new_tag = tag.parse($1, $2, tokens, @options)
@blank &&= new_tag.blank? @blank &&= new_tag.blank?
@nodelist << new_tag @nodelist << new_tag
@children << new_tag
else else
# this tag is not registered with the system # this tag is not registered with the system
# pass it to the current block for special handling or error reporting # pass it to the current block for special handling or error reporting
@@ -43,7 +39,6 @@ module Liquid
when IsVariable when IsVariable
new_var = create_variable(token) new_var = create_variable(token)
@nodelist << new_var @nodelist << new_var
@children << new_var
@blank = false @blank = false
when ''.freeze when ''.freeze
# pass # pass
@@ -64,8 +59,8 @@ module Liquid
all_warnings = [] all_warnings = []
all_warnings.concat(@warnings) if @warnings all_warnings.concat(@warnings) if @warnings
(@children || []).each do |node| (nodelist || []).each do |node|
all_warnings.concat(node.warnings || []) all_warnings.concat(node.warnings || []) if node.respond_to?(:warnings)
end end
all_warnings all_warnings