mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
avoid setting up StringScanner for parsing simple numbers
This commit is contained in:
@@ -109,12 +109,6 @@ module Liquid
|
||||
end
|
||||
|
||||
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
|
||||
case markup
|
||||
when INTEGER_REGEX
|
||||
@@ -123,6 +117,12 @@ module Liquid
|
||||
return markup.to_f
|
||||
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
|
||||
first_dot_pos = nil
|
||||
num_end_pos = nil
|
||||
|
||||
Reference in New Issue
Block a user