defer hash allocation in parse_filter_expressions

add exploration of GC object allocation

remove performance test

can actually remove one more if branch

use named locals to improve readability
This commit is contained in:
Richard Monette
2019-03-12 17:28:16 -04:00
parent d7171aa084
commit 274f078806

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