Repository navigation
Store mapping pattern entries and captures in source order - #29889
MichaReiser wants to merge 1 commit into
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 98.60%. The percentage of expected errors that received a diagnostic held steady at 98.86%. The number of fully passing files held steady at 137/146. Results for 3c2225d · Workflow run |
Memory usage reportMemory usage unchanged ✅ Results for 3c2225d · Workflow run |
|
|
0363709 to
8bf7e54
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
8bf7e54 to
1b416e6
Compare
1b416e6 to
ae3af64
Compare
ae3af64 to
1f4ded9
Compare
1f4ded9 to
44451d2
Compare
19fc665 to
c659764
Compare
c659764 to
fa3337b
Compare
fa3337b to
503f8a4
Compare
503f8a4 to
3388804
Compare
3388804 to
48b7491
Compare
48b7491 to
475a836
Compare
475a836 to
0f8d2da
Compare
0f8d2da to
3c2225d
Compare
Summary
Store each mapping-pattern key with its pattern and keep
**namecaptures in the same sequence. A source-order visitor can then read the sequence directly. For recovered syntax such ascase {**first, "x": value, **last}:, the AST retains both captures where they appeared. Consumers that ask for the rest capture continue to get the last one.The parser, formatter, code generator, and ty read this representation from the boxed AST. On a file with 1,024 mapping patterns, each with two entries and a capture, the change reduced parsing from 10,312,958 to 10,156,245 instructions (−1.52%) and the source-order walk from 415,019 to 351,531 (−15.30%). Retained syntax fell from 829,880 to 813,496 bytes (−1.97%).
These measurements predate the comparison optimizations in #30033.
The five standard parser fixtures contain no mapping patterns. Their retained syntax size was unchanged, and the three paired parser measurements ranged from −0.04% to +0.03%. The CLI comparisons produced identical output.
Test Plan
Parser and source-order tests cover valid mappings, misplaced captures, and repeated captures. The updated parser snapshots preserve the existing source ranges and diagnostics. The formatter fixtures, linter tests, ty IDE tests, and ty mdtests passed.