diff --git a/lib/internal/util.js b/lib/internal/util.js index b4b27cefb98a3c..a3ecfb8837d1d3 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -17,10 +17,10 @@ const { Promise, ReflectApply, ReflectConstruct, - RegExpPrototypeExec, RegExpPrototypeTest, SafeMap, SafeSet, + StringPrototypeSearch, StringPrototypeReplace, StringPrototypeToLowerCase, StringPrototypeToUpperCase, @@ -60,12 +60,10 @@ const colorRegExp = /\u001b\[\d\d?m/g; // eslint-disable-line no-control-regex const unpairedSurrogateRe = /\p{Surrogate}/u; function toUSVString(val) { const str = `${val}`; - // As of V8 5.5, `str.search()` (and `unpairedSurrogateRe[@@search]()`) are - // slower than `unpairedSurrogateRe.exec()`. - const match = RegExpPrototypeExec(unpairedSurrogateRe, str); - if (!match) + const index = StringPrototypeSearch(str, unpairedSurrogateRe); + if (index === -1) return str; - return _toUSVString(str, match.index); + return _toUSVString(str, index); } let uvBinding;