Skip to content

Conversation

@ckwalsh
Copy link
Contributor

@ckwalsh ckwalsh commented May 2, 2025

Summary:
This change replaces the existing RegExp replace() logic with
concatenated string slices. This avoids reallocation the result
string for each node replacement, replacing it with string slice
operations (which are implemented as O(1) string views within v8) and
a single .join(''), which can be optimized by the runtime to a single
allocation.

This probably won't make a noticable difference, but the change also
simplifies some further feature work I am attempting to add.

Test Plan:
yarn install && yarn run test --all

Stack created with Sapling. Best reviewed with ReviewStack.

Summary:
This change replaces the existing RegExp replace() logic with
concatenated string slices. This avoids reallocation the result
string for each node replacement, replacing it with string slice
operations (which are implemented as O(1) string views within v8) and
a single .join(''), which can be optimized by the runtime to a single
allocation.

This probably won't make a noticable difference, but the change also
simplifies some further feature work I am attempting to add.

Test Plan:
`yarn install && yarn run test --all`
@vladislavarsenev
Copy link
Collaborator

Like this approach, thank you🚀

@vladislavarsenev vladislavarsenev merged commit 887b7eb into trivago:v6 Oct 17, 2025
3 checks passed
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.

2 participants