Skip to content

Record (and possibly rewind) JSDoc info, create JSDoc cache separately#2796

Merged
ahejlsberg merged 1 commit intomainfrom
rewind-jsdoc-cache
Feb 16, 2026
Merged

Record (and possibly rewind) JSDoc info, create JSDoc cache separately#2796
ahejlsberg merged 1 commit intomainfrom
rewind-jsdoc-cache

Conversation

@ahejlsberg
Copy link
Member

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.

}

if p.jsdocCache == nil {
p.jsdocCache = make(map[*ast.Node][]*ast.Node, strings.Count(p.sourceText, "/**"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

@jakebailey jakebailey Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll profile it later, not blocking

(This is a map, though)

@ahejlsberg ahejlsberg added this pull request to the merge queue Feb 16, 2026
Merged via the queue into main with commit 19eaa74 Feb 16, 2026
26 checks passed
@ahejlsberg ahejlsberg deleted the rewind-jsdoc-cache branch February 16, 2026 22:14
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