Skip to content

Conversation

jakebailey
Copy link
Member

@jakebailey jakebailey commented Oct 21, 2024

The first commit changes parseList (and siblings) into methods, now that they are not generic anymore after Node was made a struct.

The second switches to using method expression syntax for parseList calls (and others), explicitly passing in p from parseList, which avoids creating a closure object just to re-pass p.

Benchmarks show a slight improvement:

goos: linux
goarch: amd64
pkg: github.com/microsoft/typescript-go/internal/compiler
cpu: Intel(R) Core(TM) i9-10900K CPU @ 3.70GHz
         │   old.txt   │              new.txt               │
         │   sec/op    │   sec/op     vs base               │
Parse-20   45.62m ± 2%   44.59m ± 1%  -2.26% (p=0.000 n=10)

         │   old.txt    │            new.txt             │
         │     B/op     │     B/op      vs base          │
Parse-20   23.59Mi ± 0%   23.59Mi ± 0%  ~ (p=0.796 n=10)

         │   old.txt   │            new.txt            │
         │  allocs/op  │  allocs/op   vs base          │
Parse-20   239.1k ± 0%   239.1k ± 0%  ~ (p=0.809 n=10)

@jakebailey jakebailey requested a review from ahejlsberg October 21, 2024 17:23
@jakebailey jakebailey merged commit 86ee6ea into main Oct 21, 2024
10 checks passed
@jakebailey jakebailey deleted the jabaile/parser-methods branch October 21, 2024 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants