diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-06-05 10:52:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-05 10:52:40 +0200 |
commit | 21c2c01ebed902c70763bb9319c3ec48c4cb5284 (patch) | |
tree | 82f01c418fc9abfb39aa370b3f3a6af820b10abb /ext/fetch/23_request.js | |
parent | adf41edda12a26a84cb8b4252404aae2a9e7ae03 (diff) |
perf: optimize RegExp usage in JS (#19364)
Towards https://github.com/denoland/deno/issues/19330
Shows about 1% improvement in the HTTP benchmark.
Diffstat (limited to 'ext/fetch/23_request.js')
-rw-r--r-- | ext/fetch/23_request.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/fetch/23_request.js b/ext/fetch/23_request.js index 4c46ebe75..daf77a834 100644 --- a/ext/fetch/23_request.js +++ b/ext/fetch/23_request.js @@ -36,7 +36,7 @@ const { ArrayPrototypeSplice, ObjectKeys, ObjectPrototypeIsPrototypeOf, - RegExpPrototypeTest, + RegExpPrototypeExec, StringPrototypeStartsWith, Symbol, SymbolFor, @@ -227,7 +227,7 @@ function validateAndNormalizeMethod(m) { } // Regular path - if (!RegExpPrototypeTest(HTTP_TOKEN_CODE_POINT_RE, m)) { + if (RegExpPrototypeExec(HTTP_TOKEN_CODE_POINT_RE, m) === null) { throw new TypeError("Method is not valid."); } const upperCase = byteUpperCase(m); |