From 71506ad54e43fdf0ed476a47cc67c7635db61824 Mon Sep 17 00:00:00 2001 From: Michael Go Date: Mon, 18 Nov 2024 20:12:10 -0400 Subject: [PATCH] avoid setting up StringScanner for parsing simple numbers --- lib/liquid/expression.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/liquid/expression.rb b/lib/liquid/expression.rb index 0a569e99..0d8a4471 100644 --- a/lib/liquid/expression.rb +++ b/lib/liquid/expression.rb @@ -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