Skip to content

Commit b37fa98

Browse files
committed
Clean up tokenizer: remove unused StringScanner setup and regex constants\n\nResult: {"status":"keep","combined_µs":3490,"parse_µs":2331,"render_µs":1159,"allocations":24882}
1 parent e25f2f1 commit b37fa98

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

autoresearch.jsonl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
{"run":11,"commit":"c09e722","metric":3889,"metrics":{"parse_µs":2770,"render_µs":1119,"allocations":24766},"status":"discard","description":"TruthyCondition for simple if checks: -115 allocs but YJIT polymorphism at evaluate call site hurts speed","timestamp":1773349649377,"segment":0}
1313
{"run":12,"commit":"c09e722","metric":4150,"metrics":{"parse_µs":2769,"render_µs":1381,"allocations":24881},"status":"discard","description":"Index loop for filters: YJIT optimizes each+destructure better than manual indexing","timestamp":1773349699285,"segment":0}
1414
{"run":13,"commit":"b7ae55f","metric":3556,"metrics":{"parse_µs":2388,"render_µs":1168,"allocations":24882},"status":"keep","description":"Replace StringScanner tokenizer with String#byteindex — 12% faster parse, no regex overhead for delimiter finding","timestamp":1773349875890,"segment":0}
15+
{"run":14,"commit":"e25f2f1","metric":3464,"metrics":{"parse_µs":2335,"render_µs":1129,"allocations":24882},"status":"keep","description":"Confirmation run: byteindex tokenizer consistently 3,400-3,600µs","timestamp":1773349889465,"segment":0}

lib/liquid/tokenizer.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ module Liquid
66
class Tokenizer
77
attr_reader :line_number, :for_liquid_tag
88

9-
TAG_END = /%\}/
10-
TAG_OR_VARIABLE_START = /\{[\{\%]/
11-
NEWLINE = /\n/
12-
139
OPEN_CURLEY = "{".ord
1410
CLOSE_CURLEY = "}".ord
1511
PERCENTAGE = "%".ord
@@ -27,11 +23,7 @@ def initialize(
2723
@offset = 0
2824
@tokens = []
2925

30-
if @source
31-
@ss = string_scanner
32-
@ss.string = @source
33-
tokenize
34-
end
26+
tokenize if @source
3527
end
3628

3729
def shift

0 commit comments

Comments
 (0)