Record (and possibly rewind) JSDoc info, create JSDoc cache separately#2796
Merged
ahejlsberg merged 1 commit intomainfrom Feb 16, 2026
Merged
Record (and possibly rewind) JSDoc info, create JSDoc cache separately#2796ahejlsberg merged 1 commit intomainfrom
ahejlsberg merged 1 commit intomainfrom
Conversation
jakebailey
reviewed
Feb 16, 2026
| } | ||
|
|
||
| if p.jsdocCache == nil { | ||
| p.jsdocCache = make(map[*ast.Node][]*ast.Node, strings.Count(p.sourceText, "/**")) |
Member
There was a problem hiding this comment.
This presizing was important for perf; can this be retained somewhere? Maybe not, given we don't want to do this when we're not parsing out jsdoc.
(I can test the perf of this later)
Member
Author
There was a problem hiding this comment.
I think presizing is a lot more important for maps. We now collect the JSDoc information in an array and then build the map as we finalize the source file. The array is subject to reallocation, but the map is preallocated in its exact final size. We could presize the array, but I doubt it matters much.
Member
There was a problem hiding this comment.
I'll profile it later, not blocking
(This is a map, though)
jakebailey
approved these changes
Feb 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is a follow-up to #2795 that records (and possibly rewinds) JSDoc comment occurrences and creates the JSDoc cache as a separate step when finalizing a source file object.
No tests associated with this PR as all it does is eliminate speculatively parsed and discarded JSDoc objects from the JSDoc cache.