Merge pull request #1073 from Shopify/defer-alloc-hash

defer hash allocation until needed for unparsed_args
This commit is contained in:
Richard Monette
2019-03-20 13:34:48 -04:00
committed by GitHub
+3 -2
View File
@@ -95,16 +95,17 @@ module Liquid
def parse_filter_expressions(filter_name, unparsed_args)
filter_args = []
keyword_args = {}
keyword_args = nil
unparsed_args.each do |a|
if matches = a.match(JustTagAttributes)
keyword_args ||= {}
keyword_args[matches[1]] = Expression.parse(matches[2])
else
filter_args << Expression.parse(a)
end
end
result = [filter_name, filter_args]
result << keyword_args unless keyword_args.empty?
result << keyword_args if keyword_args
result
end