mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-18 18:30:40 -07:00
more micro optimization
This commit is contained in:
@@ -15,7 +15,6 @@ module Liquid
|
|||||||
PERCENTAGE = 37
|
PERCENTAGE = 37
|
||||||
|
|
||||||
def initialize(source, line_numbers = false, line_number: nil, for_liquid_tag: false)
|
def initialize(source, line_numbers = false, line_number: nil, for_liquid_tag: false)
|
||||||
@source = source
|
|
||||||
@line_number = line_number || (line_numbers ? 1 : nil)
|
@line_number = line_number || (line_numbers ? 1 : nil)
|
||||||
@for_liquid_tag = for_liquid_tag
|
@for_liquid_tag = for_liquid_tag
|
||||||
@ss = StringScanner.new(source)
|
@ss = StringScanner.new(source)
|
||||||
@@ -81,27 +80,23 @@ module Liquid
|
|||||||
@ss.pos += 2
|
@ss.pos += 2
|
||||||
|
|
||||||
# it is possible to see a {% before a }} so we need to check for that
|
# it is possible to see a {% before a }} so we need to check for that
|
||||||
byte_a = @ss.peek_byte
|
byte_a = @ss.scan_byte
|
||||||
@ss.pos += 1
|
|
||||||
|
|
||||||
until @ss.eos?
|
until @ss.eos?
|
||||||
while byte_a != OPEN_CURLEY && byte_a != CLOSE_CURLEY && @ss.eos? == false
|
while byte_a != OPEN_CURLEY && byte_a != CLOSE_CURLEY && @ss.eos? == false
|
||||||
byte_a = @ss.peek_byte
|
byte_a = @ss.scan_byte
|
||||||
@ss.pos += 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
break if @ss.eos?
|
break if @ss.eos?
|
||||||
|
|
||||||
byte_b = @ss.peek_byte
|
byte_b = @ss.scan_byte
|
||||||
|
|
||||||
if byte_b != CLOSE_CURLEY && byte_b != PERCENTAGE
|
if byte_b != CLOSE_CURLEY && byte_b != PERCENTAGE
|
||||||
@ss.pos += 1
|
|
||||||
byte_a = byte_b
|
byte_a = byte_b
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
if byte_a == CLOSE_CURLEY && byte_b == CLOSE_CURLEY
|
if byte_a == CLOSE_CURLEY && byte_b == CLOSE_CURLEY
|
||||||
@ss.pos += 1
|
|
||||||
return @ss.string.byteslice(start, @ss.pos - start)
|
return @ss.string.byteslice(start, @ss.pos - start)
|
||||||
elsif byte_a == OPEN_CURLEY && byte_b == PERCENTAGE
|
elsif byte_a == OPEN_CURLEY && byte_b == PERCENTAGE
|
||||||
return next_tag_token(start)
|
return next_tag_token(start)
|
||||||
|
|||||||
Reference in New Issue
Block a user