mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Reduce temporary objects during variable/filter parsing
This commit is contained in:
@@ -36,13 +36,13 @@ module Liquid
|
|||||||
|
|
||||||
def lax_parse(markup)
|
def lax_parse(markup)
|
||||||
@filters = []
|
@filters = []
|
||||||
if match = markup.match(/\s*(#{QuotedFragment})(.*)/om)
|
if markup =~ /\s*(#{QuotedFragment})(.*)/om
|
||||||
@name = match[1]
|
@name = Regexp.last_match(1)
|
||||||
if match[2].match(/#{FilterSeparator}\s*(.*)/om)
|
if Regexp.last_match(2) =~ /#{FilterSeparator}\s*(.*)/om
|
||||||
filters = Regexp.last_match(1).scan(FilterParser)
|
filters = Regexp.last_match(1).scan(FilterParser)
|
||||||
filters.each do |f|
|
filters.each do |f|
|
||||||
if matches = f.match(/\s*(\w+)/)
|
if f =~ /\s*(\w+)/
|
||||||
filtername = matches[1]
|
filtername = Regexp.last_match(1)
|
||||||
filterargs = f.scan(/(?:#{FilterArgumentSeparator}|#{ArgumentSeparator})\s*((?:\w+\s*\:\s*)?#{QuotedFragment})/o).flatten
|
filterargs = f.scan(/(?:#{FilterArgumentSeparator}|#{ArgumentSeparator})\s*((?:\w+\s*\:\s*)?#{QuotedFragment})/o).flatten
|
||||||
@filters << [filtername, filterargs]
|
@filters << [filtername, filterargs]
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user