From aa8a935f620a053cc9c3c65587b433f3e8d3a6e9 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Thu, 30 Oct 2025 18:45:11 -0700 Subject: Use a classic struct iterator instead of iter.Pull MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit iter.Pull doesn't provide much value here. Actually the lexer is probably simpler this way, and iter.Pull also destroys stack traces for panics in the lexer. Ouch goos: linux goarch: amd64 pkg: roseh.moe/pkg/ccl cpu: AMD Ryzen 9 5900X 12-Core Processor │ baseline.txt │ itern't.txt │ │ sec/op │ sec/op vs base │ Lex-24 1.436µ ± 0% 1.320µ ± 0% -8.05% (p=0.000 n=20) Parse-24 7.846µ ± 0% 4.801µ ± 0% -38.82% (p=0.000 n=20) geomean 3.356µ 2.517µ -24.99% --- ccl_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'ccl_test.go') diff --git a/ccl_test.go b/ccl_test.go index ab4833f..53b2a24 100644 --- a/ccl_test.go +++ b/ccl_test.go @@ -684,8 +684,13 @@ func BenchmarkLex(b *testing.B) { repeated: [5, 6] `) for b.Loop() { - for _, err := range tokens(msg) { + l := newLexer(msg) + for { + _, err := l.next() if err != nil { + if err == errEOF { + break + } b.Fatal(err) } } -- cgit v1.3.1