add StringScannerPool for thread safety

This commit is contained in:
Michael Go
2025-01-07 14:32:07 -04:00
parent eff5c5de8e
commit 3c16c27ee1
5 changed files with 57 additions and 46 deletions
+3 -6
View File
@@ -72,10 +72,6 @@ module Liquid
CACHE = LruRedux::Cache.new(10_000) # most themes would have less than 2,000 unique expression
class << self
def string_scanner
@ss ||= StringScanner.new("")
end
def parse(markup)
return unless markup
@@ -106,8 +102,7 @@ module Liquid
end
def parse_number(markup)
ss = string_scanner
ss.string = markup
ss = StringScannerPool.pop(markup)
is_integer = true
last_dot_pos = nil
@@ -147,6 +142,8 @@ module Liquid
# we should never reach this point
false
end
ensure
StringScannerPool.release(ss)
end
end
end