Skip to content

Remove fancy-regex dependency#840

Merged
reese merged 1 commit intotrunkfrom
reese-fancy-regex
Mar 17, 2026
Merged

Remove fancy-regex dependency#840
reese merged 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.

(This is also part of #832, since fancy-regex takes UTF-8 strings.)

@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
@reese reese requested a review from froydnj March 17, 2026 00:14
Copy link
Collaborator

@froydnj froydnj left a comment

Choose a reason for hiding this comment

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

I assume we have good test coverage for this?

@reese
Copy link
Collaborator Author

reese commented Mar 17, 2026

Yeah, this should be covered pretty thoroughly by the string literals stress test

@reese reese merged commit f9fdbf1 into trunk Mar 17, 2026
9 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