Skip to content

chore(core): use regex.exec instead of string.match#5331

Merged
mcollina merged 1 commit into
nodejs:mainfrom
aduh95:regex-exec
May 29, 2026
Merged

chore(core): use regex.exec instead of string.match#5331
mcollina merged 1 commit into
nodejs:mainfrom
aduh95:regex-exec

Conversation

@aduh95
Copy link
Copy Markdown
Contributor

@aduh95 aduh95 commented May 28, 2026

string.match(regex) calls internally regex[Symbol.match]() which itself calls regex.exec(). We can shortcut this and call .exec directly (from my testing, it's marginally faster in normal conditions, and much faster if any of String.prototype and/or RegExp.prototype have been mutated)

This relates to...

Rationale

Changes

Features

Bug Fixes

Breaking Changes and Deprecations

Status

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.21%. Comparing base (99912e8) to head (0f78c34).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5331   +/-   ##
=======================================
  Coverage   93.21%   93.21%           
=======================================
  Files         110      110           
  Lines       36598    36599    +1     
=======================================
+ Hits        34116    34117    +1     
  Misses       2482     2482           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
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

@mcollina mcollina merged commit 7235cbb into nodejs:main May 29, 2026
38 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.

4 participants