Skip to content

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

Open
clydin wants to merge 1 commit into
angular:mainfrom
clydin:perf/optimize-remove-sourcemapping-url
Open

refactor(@angular/build): optimize removeSourceMappingURL with pre-check and range slicing#33780
clydin wants to merge 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer 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.

1 participant