Repository navigation
Lazily collect source file identifiers - #4731
Conversation
|
TypeScript Bot (@typescript-bot) perf test this |
There was a problem hiding this comment.
Pull request overview
Defers source-file identifier collection until emit-time uniqueness checks need it and removes parser string interning.
Changes:
- Lazily scans source text for identifiers and relevant literals.
- Caches identifier sets safely with
sync.Once. - Removes eager parser interning and identifier-map population.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
internal/printer/utilities.go |
Computes identifiers during uniqueness checks. |
internal/parser/parser.go |
Removes eager interning and collection. |
internal/parser/jsdoc.go |
Removes obsolete JSDoc interning. |
internal/ast/ast.go |
Adds lazy identifier-set storage and accessor. |
|
Jake Bailey (@jakebailey) Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
lspComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
startupComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||
| _, ok := sourceFile.Identifiers[name] | ||
| return !ok | ||
| identifiers := sourceFile.GetIdentifiers(func(sourceFile *ast.SourceFile) collections.Set[string] { |
There was a problem hiding this comment.
Not a mega fan of this pattern, might change to be more like JSDoc lazy
There was a problem hiding this comment.
Though this is not dissimilar to Bind, theoretically
Daniel Rosenwasser (DanielRosenwasser)
left a comment
There was a problem hiding this comment.
I think we'd actually end up needing a walk of the tree for these.
|
TypeScript Bot (@typescript-bot) perf test this |
|
Daniel Rosenwasser (@DanielRosenwasser) Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
lspComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
startupComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
We do this eagerly, but only need it in certain emit cases. Defer the work until requested, and then clean up the interning code (which does not appear to help and doesn't help in maps anyway).