mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-19 19:00:39 -07:00
avoid setting up StringScanner for parsing simple numbers
This commit is contained in:
@@ -109,12 +109,6 @@ module Liquid
|
|||||||
end
|
end
|
||||||
|
|
||||||
def parse_number(markup, ss)
|
def parse_number(markup, ss)
|
||||||
ss.string = markup
|
|
||||||
# the first byte must be a digit, a period, or a dash
|
|
||||||
byte = ss.scan_byte
|
|
||||||
|
|
||||||
return false if byte != DASH && byte != DOT && (byte < ZERO || byte > NINE)
|
|
||||||
|
|
||||||
# check if the markup is simple integer or float
|
# check if the markup is simple integer or float
|
||||||
case markup
|
case markup
|
||||||
when INTEGER_REGEX
|
when INTEGER_REGEX
|
||||||
@@ -123,6 +117,12 @@ module Liquid
|
|||||||
return markup.to_f
|
return markup.to_f
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ss.string = markup
|
||||||
|
# the first byte must be a digit, a period, or a dash
|
||||||
|
byte = ss.scan_byte
|
||||||
|
|
||||||
|
return false if byte != DASH && byte != DOT && (byte < ZERO || byte > NINE)
|
||||||
|
|
||||||
# The markup could be a float with multiple dots
|
# The markup could be a float with multiple dots
|
||||||
first_dot_pos = nil
|
first_dot_pos = nil
|
||||||
num_end_pos = nil
|
num_end_pos = nil
|
||||||
|
|||||||
Reference in New Issue
Block a user