Skip to content

Commit 5f18261

Browse files
committed
restore perf tweak that made a meaningful difference in regex construction perf tests
1 parent 5a0931c commit 5f18261

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/xregexp.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,9 @@ XRegExp.isInstalled = (feature) => !!(features[feature]);
980980
* XRegExp.isRegExp(RegExp('^', 'm')); // -> true
981981
* XRegExp.isRegExp(XRegExp('(?s).')); // -> true
982982
*/
983-
XRegExp.isRegExp = (value) => isType(value, 'RegExp');
983+
XRegExp.isRegExp = (value) => Object.prototype.toString.call(value) === '[object RegExp]';
984+
// Same as `isType(value, 'RegExp')`, but avoiding that function call here for perf since
985+
// `isRegExp` is used heavily by internals including regex construction
984986

985987
/**
986988
* Returns the first matched string, or in global mode, an array containing all matched strings.

0 commit comments

Comments
 (0)