Skip to content

refactor(@angular/build): optimize removeSourceMappingURL with pre-check and range slicing - #33780

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
clydin:perf/optimize-remove-sourcemapping-url
Aug 6, 2026
Merged

refactor(@angular/build): optimize removeSourceMappingURL with pre-check and range slicing#33780
alan-agius4 merged 1 commit into
angular:mainfrom
clydin:perf/optimize-remove-sourcemapping-url

Conversation

@clydin

@clydin clydin commented Aug 5, 2026

Copy link
Copy Markdown
Member

Add an early substring check to immediately return the original code when no source map comment is present in a file. In addition, replace the character-by-character string accumulator with range slicing to eliminate temporary single-character string allocations on large files, and add unit tests covering zero-comment early returns and CRLF line endings.

…eck and range slicing

Add an early substring check to immediately return the original code when no source map comment is present in a file. In addition, replace the character-by-character string accumulator with range slicing to eliminate temporary single-character string allocations on large files, and add unit tests covering zero-comment early returns and CRLF line endings.

@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 removeSourceMappingURL function by introducing a fast-path check when no sourcemap comment is present and refactoring the character-by-character reconstruction to use string slicing with a lastCopiedIndex tracker. Additionally, new unit tests are added to verify the behavior with CRLF newlines and inputs without sourcemap comments. There are no review comments, and we have no feedback to provide.

@clydin clydin added the target: patch This PR is targeted for the next patch release label Aug 6, 2026
@clydin
clydin requested a review from alan-agius4 August 6, 2026 00:35
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Aug 6, 2026
@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 6, 2026
@alan-agius4
alan-agius4 merged commit a8f451b into angular:main Aug 6, 2026
42 of 43 checks passed
@alan-agius4

Copy link
Copy Markdown
Collaborator

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 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