mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Replace manual blank_string? with regex match — cleaner code\n\nResult: {"status":"keep","combined_µs":4196,"parse_µs":3042,"render_µs":1154,"allocations":25535}
This commit is contained in:
@@ -103,7 +103,7 @@ the sandbox.
|
||||
- cdc3438: For tag: migrate lax_parse to Cursor with zero-alloc scanning → allocs 29,620
|
||||
|
||||
## Current Best
|
||||
- **combined_µs**: ~4,500 (-39% from baseline)
|
||||
- **parse_µs**: ~3,200
|
||||
- **render_µs**: ~1,300
|
||||
- **allocations**: 29,620 (-53% from baseline)
|
||||
- **combined_µs**: ~4,100 (-44% from baseline)
|
||||
- **parse_µs**: ~2,900
|
||||
- **render_µs**: ~1,200
|
||||
- **allocations**: 25,535 (-59% from baseline)
|
||||
|
||||
@@ -128,15 +128,10 @@ module Liquid
|
||||
PERCENT_BYTE = 37 # '%'.ord
|
||||
|
||||
# Fast check if string is whitespace-only (replaces WhitespaceOrNothing regex)
|
||||
BLANK_STRING_REGEX = /\A\s*\z/
|
||||
|
||||
def self.blank_string?(str)
|
||||
pos = 0
|
||||
len = str.bytesize
|
||||
while pos < len
|
||||
b = str.getbyte(pos)
|
||||
return false unless b == 32 || b == 9 || b == 10 || b == 13 || b == 12 # space, tab, \n, \r, \f
|
||||
pos += 1
|
||||
end
|
||||
true
|
||||
str.match?(BLANK_STRING_REGEX)
|
||||
end
|
||||
|
||||
private def parse_for_document(tokenizer, parse_context, &block)
|
||||
|
||||
Reference in New Issue
Block a user