Skip to content

Remove fancy-regex dependency#840

Open
reese wants to merge 1 commit intotrunkfrom
reese-fancy-regex
Open

Remove fancy-regex dependency#840
reese wants to merge 1 commit intotrunkfrom
reese-fancy-regex

Conversation

@reese
Copy link
Collaborator

@reese reese commented Mar 4, 2026

Currently, any time we convert a string to use double quotes, we compile and run a regex for every string. Benchmarking the large test fixtures, Regex::new alone takes up more than 2% of the overall runtime, with single_to_double_quoted taking up 3.5%. We could cache these or precompile the most common ones, but honestly using a regex here is overkill -- we're basically just checking for slashes followed by one of the delimiters, which we could do by iterating over the characters instead.

Replacing the fancy-regex usage with a manual implementation shows single_to_double_quoted going from 3.5% -> 0.5% in my benchmarking, plus it's one fewer dependency.

@reese reese force-pushed the reese-fancy-regex branch from 2102daf to 8de14a9 Compare March 4, 2026 02:28
@reese reese marked this pull request as ready for review March 4, 2026 02:45
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.

1 participant