Skip to content

perf(lib/pluginutils): cache rc version regex #5940

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2025
Merged

perf(lib/pluginutils): cache rc version regex #5940

merged 1 commit into from
Jan 14, 2025

Conversation

Fdawgs
Copy link
Member

@Fdawgs Fdawgs commented Jan 11, 2025

Regex is expensive to create and garbage collect, so this should help a tad rather than having to create a new regexp object every time a plugin version is checked.

Checklist

Signed-off-by: Frazer Smith <frazer.dev@icloud.com>
Copy link
Member

@jsumners jsumners left a comment

Choose a reason for hiding this comment

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

I am willing to bet this gets optimized out automatically.

@gurgunday
Copy link
Member

gurgunday commented Jan 11, 2025

From what I know, and I read it on some blog sometime ago, the // syntax gets optimized very fast as it restricts dynamic expressions inside, contrary to the RegExp constructor

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

I generally got burned a few times by the internal state that is retained by running the same regexp multiple times, and I totally forget that it is safe to do so sometimes.

gurgunday
gurgunday approved these changes Jan 11, 2025
@Fdawgs Fdawgs merged commit 4467cfc into main Jan 14, 2025
27 checks passed
@Fdawgs Fdawgs deleted the Fdawgs-patch-2 branch January 14, 2025 17:09
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.

4 participants