remove-markdown icon indicating copy to clipboard operation
remove-markdown copied to clipboard

Performance: Move regex initializations to module scope

Open kulturpessimist opened this issue 7 months ago • 1 comments

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 avatar May 23 '25 14:05 kulturpessimist

Done with Copilot but Tests are passing.

kulturpessimist avatar May 23 '25 14:05 kulturpessimist

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.

swift502 avatar Dec 23 '25 20:12 swift502