apply "o" option to regexps to improve process time

This commit is contained in:
akira yamada
2012-04-02 19:31:55 +09:00
parent c10f936d2a
commit 84ed3d9964

View File

@@ -18,14 +18,14 @@ module Liquid
@markup = markup
@name = nil
@filters = []
if match = markup.match(/\s*(#{QuotedFragment})(.*)/)
if match = markup.match(/\s*(#{QuotedFragment})(.*)/o)
@name = match[1]
if match[2].match(/#{FilterSeparator}\s*(.*)/)
if match[2].match(/#{FilterSeparator}\s*(.*)/o)
filters = Regexp.last_match(1).scan(FilterParser)
filters.each do |f|
if matches = f.match(/\s*(\w+)/)
filtername = matches[1]
filterargs = f.scan(/(?:#{FilterArgumentSeparator}|#{ArgumentSeparator})\s*(#{QuotedFragment})/).flatten
filterargs = f.scan(/(?:#{FilterArgumentSeparator}|#{ArgumentSeparator})\s*(#{QuotedFragment})/o).flatten
@filters << [filtername.to_sym, filterargs]
end
end