perf(packages/codegen): eagerly initialize mapNames - #25979
Merged
graphite-app[bot] merged 1 commit intoAug 24, 2026
Merged
graphite-app[bot] merged 1 commit into
graphite-app[bot] merged 1 commit into
Conversation
This was referenced Aug 22, 2026
This was referenced Aug 22, 2026
Merged
Member
Author
This was referenced Aug 22, 2026
overlookmotel
marked this pull request as ready for review
August 22, 2026 01:10
Contributor
There was a problem hiding this comment.
Pull request overview
Updates source-map generation to eagerly initialize mapNames, removing repeated lazy-initialization checks.
Changes:
- Initialize
mapNamesalongsidemapPositions. - Simplify named mapping writes.
- Update source-map access and assertions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
packages/codegen/src-js/state.ts |
Eagerly initializes mapNames. |
packages/codegen/src-js/print/write.ts |
Removes lazy array initialization. |
packages/codegen/src-js/print/source_map.ts |
Uses direct initialized-array access. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
This was referenced Aug 22, 2026
graphite-app
Bot
force-pushed
the
om/08-18-perf_packages_codegen_split_recording_mappings_into_multiple_functions
branch
from
August 22, 2026 09:39
59742d9 to
dc29479
Compare
graphite-app
Bot
force-pushed
the
om/08-18-perf_packages_codegen_eagerly_initialize_mapnames_
branch
from
August 22, 2026 09:40
cd92cea to
57c3dd8
Compare
graphite-app
Bot
force-pushed
the
om/08-18-perf_packages_codegen_split_recording_mappings_into_multiple_functions
branch
from
August 22, 2026 10:31
dc29479 to
b660279
Compare
graphite-app
Bot
force-pushed
the
om/08-18-perf_packages_codegen_eagerly_initialize_mapnames_
branch
from
August 22, 2026 10:31
57c3dd8 to
1652053
Compare
graphite-app
Bot
force-pushed
the
om/08-18-perf_packages_codegen_split_recording_mappings_into_multiple_functions
branch
from
August 22, 2026 13:33
b660279 to
f174d21
Compare
graphite-app
Bot
force-pushed
the
om/08-18-perf_packages_codegen_eagerly_initialize_mapnames_
branch
from
August 22, 2026 13:34
1652053 to
d6c729f
Compare
camc314
approved these changes
Aug 24, 2026
Contributor
Merge activity
|
graphite-app
Bot
changed the base branch from
om/08-18-perf_packages_codegen_split_recording_mappings_into_multiple_functions
to
graphite-base/25979
August 24, 2026 07:43
graphite-app Bot
pushed a commit
that referenced
this pull request
Aug 24, 2026
Previously `mapNames` property of state was lazily initialized - it started as `null`, and an array is only created when a named mapping is written. Often lazy initialization is a good strategy, but in this case IMO it's a poor trade-off - it adds a check for every named mapping that's written in return for saving a single allocation per file, and only in files which produce a source map with no names. Allocating 1 empty array is very cheap.
graphite-app
Bot
force-pushed
the
om/08-18-perf_packages_codegen_eagerly_initialize_mapnames_
branch
from
August 24, 2026 07:49
d6c729f to
8621f31
Compare
graphite-app
Bot
requested review from
Boshen,
Dunqing,
Sysix and
leaysgur
as code owners
August 24, 2026 07:49
graphite-app
Bot
changed the base branch from
graphite-base/25979
to
om/08-18-perf_packages_codegen_split_recording_mappings_into_multiple_functions
August 24, 2026 07:49
Base automatically changed from
om/08-18-perf_packages_codegen_split_recording_mappings_into_multiple_functions
to
main
August 24, 2026 07:53
Previously `mapNames` property of state was lazily initialized - it started as `null`, and an array is only created when a named mapping is written. Often lazy initialization is a good strategy, but in this case IMO it's a poor trade-off - it adds a check for every named mapping that's written in return for saving a single allocation per file, and only in files which produce a source map with no names. Allocating 1 empty array is very cheap.
graphite-app
Bot
force-pushed
the
om/08-18-perf_packages_codegen_eagerly_initialize_mapnames_
branch
from
August 24, 2026 09:00
5cc70fe to
53f6270
Compare
graphite-app
Bot
deleted the
om/08-18-perf_packages_codegen_eagerly_initialize_mapnames_
branch
August 24, 2026 09:04
graphite-app Bot
pushed a commit
that referenced
this pull request
Aug 24, 2026
### 🚀 Features - b6e9e5e minifier: Fold switch stmt whose parent is not block stmt (#25403) (Armano) ### 🐛 Bug Fixes - 8a9bdbd estree: Include decorators in `FormalParameterRest ` spans (#26021) (camc314) - 6f0c7cf minifier: Avoid merging `if` to `for` in sloppy mode when containing function declaration (#25638) (sapphi-red) - 2cde1f6 rust: Address nightly deprecations (#25998) (Boshen) - 6c5ad1b codegen: Only add mapping names for `PrivateIdentifier`s which have changed (#25958) (overlookmotel) - 2dad1e0 parser: Track irregular line terminators in trivia (#25947) (camc314) - 58ba651 minifier: Avoid merging `if` to `for` when the body contains a function declaration (#25637) (sapphi-red) - a185ac3 codegen: Print `#` before private identifier in TS signature key (#25938) (overlookmotel) - af82a07 minifier: Keep unary `+` when the other operand has side effects (#25645) (Kotaro Chikuba) ### ⚡ Performance - 53f6270 packages/codegen: Eagerly initialize `mapNames` (#25979) (overlookmotel) - 5b43c60 packages/codegen: Split recording mappings into multiple functions (#25978) (overlookmotel) - cc947b5 packages/codegen: Reduce property lookups (#25977) (overlookmotel) - c22a9cc packages/codegen: Combine condition checks (#25976) (overlookmotel) - 215a6a5 packages/codegen: Add functions for writing/marking unnamed mappings (#25975) (overlookmotel) - fe444cc codegen: Avoid allocations for single comment anchors (#25598) (camc314) - a0aee81 minifier: Do not rebuild expression when substituting void to null (#25964) (Armano) - 1004439 packages/codegen: Merge `mark` and `write` calls in `printImportAttributes` (#25972) (overlookmotel) - 94c8a34 packages/codegen: Remove `node` param from `printString` and `printNonNegativeFloat` (#25971) (overlookmotel) - 7e2b4b3 packages/codegen: `printNonNegativeFloat` write mapping directly (#25968) (overlookmotel) - f09c8ab minifier: Avoid creation of unnecessary conditional expressions (#25931) (Armano) - 53ff080 packages/codegen: Remove `lastWasPostfixClose` (#25888) (overlookmotel) ### 📚 Documentation - 07de646 packages/codegen: Fix JSDoc comments on `write*` methods (#25966) (overlookmotel) - 3b09c04 packages/codegen: Clarify comment (#25959) (overlookmotel)
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.

Previously
mapNamesproperty of state was lazily initialized - it started asnull, and an array is only created when a named mapping is written.Often lazy initialization is a good strategy, but in this case IMO it's a poor trade-off - it adds a check for every named mapping that's written in return for saving a single allocation per file, and only in files which produce a source map with no names. Allocating 1 empty array is very cheap.