Performance: Move regex initializations to module scope#98
Open
kulturpessimist wants to merge 1 commit intozuchka:mainfrom
Open
Performance: Move regex initializations to module scope#98kulturpessimist wants to merge 1 commit intozuchka:mainfrom
kulturpessimist wants to merge 1 commit intozuchka:mainfrom
Conversation
Author
|
Done with Copilot but Tests are passing. |
I checked if any regex string has changed, and the The ! symbol escape has been removed. I believe it's functionally equivalent, but it has been modified. |
swift502
reviewed
Dec 23, 2025
| @@ -1,3 +1,26 @@ | |||
| // Regex-Konstrukte in den äußeren Scope verschoben | |||
There was a problem hiding this comment.
Shouldn't all comments be in English for consistency?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
This PR moves all regular expression initializations in index.js to the module (outer) scope, so they are only created once and reused on every function call. This improves performance, especially when the function is called frequently.
All regex patterns are now declared as constants at the top of the file
No change in functionality; all tests continue to pass
Motivation: Previously, regex objects were re-initialized on every function call, which could impact performance. With this change, regex objects are created once and reused.
Tests: All existing tests (npm test) pass successfully.
As requested with proposal from @punkpeye