Skip to content

Save off another closure in emitResolver #1311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jakebailey
Copy link
Member

This accounts for basically all of the allocs in declaration emit (and therefore, declaration diags in the editor, where this is 30% of all allocs). For tsc -p ./src/compiler, the number of allocs is reduced from 4431617 to 3552713.

@jakebailey jakebailey requested review from weswigham and Copilot June 28, 2025 20:12
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR reduces allocation overhead in declaration emit by caching method closures in the emitResolver.

  • Introduces a newEmitResolver constructor to initialize closure fields once.
  • Adds an aliasMarkingVisitor field and renames the original method to aliasMarkingVisitorWorker to avoid per-call allocations.
  • Updates GetEmitResolver to use the new constructor and adjusts the interface assertion.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/checker/emitresolver.go Added newEmitResolver, aliasMarkingVisitor field, renamed method, updated interface assertion
internal/checker/checker.go Updated GetEmitResolver to invoke newEmitResolver

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.

1 participant