Skip to content

perf(@angular/build): use Map for chunk asset size lookups in budget calculator - #33803

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
alan-agius4:perf-budget-calculator-map
Aug 7, 2026
Merged

perf(@angular/build): use Map for chunk asset size lookups in budget calculator#33803
alan-agius4 merged 1 commit into
angular:mainfrom
alan-agius4:perf-budget-calculator-map

Conversation

@alan-agius4

Copy link
Copy Markdown
Collaborator

Caches chunk asset sizes in a Map to reduce asset size lookups from repeated linear array searches to constant time during budget calculation.

@angular-robot angular-robot Bot added area: performance Issues related to performance area: @angular/build labels Aug 7, 2026
@alan-agius4
alan-agius4 requested a review from clydin August 7, 2026 14:33
@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Aug 7, 2026
@alan-agius4
alan-agius4 force-pushed the perf-budget-calculator-map branch from c778f2b to 244e474 Compare August 7, 2026 14:34
@alan-agius4
alan-agius4 marked this pull request as ready for review August 7, 2026 14:34

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request optimizes the bundle size calculation by caching asset sizes in a Map to avoid repeated linear searches. The reviewer suggested a further performance improvement to avoid intermediate array allocations when initializing the Map, as well as using a local variable to eliminate optional chaining inside the map callback.

Comment thread packages/angular/build/src/utils/bundle-calculator.ts Outdated
…calculator

Caches chunk asset sizes in a Map to reduce asset size lookups from repeated linear array searches to constant time during budget calculation.
@alan-agius4
alan-agius4 force-pushed the perf-budget-calculator-map branch from 244e474 to 6c27c8d Compare August 7, 2026 14:37
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Aug 7, 2026
@alan-agius4
alan-agius4 merged commit 19c91e4 into angular:main Aug 7, 2026
40 checks passed
@alan-agius4
alan-agius4 deleted the perf-budget-calculator-map branch August 7, 2026 16:37
@alan-agius4

Copy link
Copy Markdown
Collaborator Author

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build area: performance Issues related to performance target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants