Skip to content

Performance: Move regex initializations to module scope#98

Open
kulturpessimist wants to merge 1 commit intozuchka:mainfrom
kulturpessimist:main
Open

Performance: Move regex initializations to module scope#98
kulturpessimist wants to merge 1 commit intozuchka:mainfrom
kulturpessimist:main

Conversation

@kulturpessimist
Copy link

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

@kulturpessimist
Copy link
Author

Done with Copilot but Tests are passing.

@swift502
Copy link

swift502 commented Dec 23, 2025

Done with Copilot

I checked if any regex string has changed, and the IMAGE_REGEX string is different now.

The ! symbol escape has been removed. I believe it's functionally equivalent, but it has been modified.

@@ -1,3 +1,26 @@
// Regex-Konstrukte in den äußeren Scope verschoben
Copy link

@swift502 swift502 Dec 23, 2025

Choose a reason for hiding this comment

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

Shouldn't all comments be in English for consistency?

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