Avoid keeping track of two lists of nodes during parsing.

This commit is contained in:
Dylan Thacker-Smith
2014-02-27 20:51:05 -05:00
parent c0832ce0d1
commit 8e45b44b21

View File

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