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/web/01_mimesniff.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/web/01_mimesniff.js')
-rw-r--r-- | ext/web/01_mimesniff.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/ext/web/01_mimesniff.js b/ext/web/01_mimesniff.js index ad89f33cd..7d402e080 100644 --- a/ext/web/01_mimesniff.js +++ b/ext/web/01_mimesniff.js @@ -13,6 +13,7 @@ const { MapPrototypeHas, MapPrototypeSet, RegExpPrototypeTest, + RegExpPrototypeExec, SafeMap, SafeMapIterator, StringPrototypeReplaceAll, @@ -197,7 +198,7 @@ function serializeMimeType(mimeType) { for (const param of new SafeMapIterator(mimeType.parameters)) { serialization += `;${param[0]}=`; let value = param[1]; - if (!RegExpPrototypeTest(HTTP_TOKEN_CODE_POINT_RE, value)) { + if (RegExpPrototypeExec(HTTP_TOKEN_CODE_POINT_RE, value) === null) { value = StringPrototypeReplaceAll(value, "\\", "\\\\"); value = StringPrototypeReplaceAll(value, '"', '\\"'); value = `"${value}"`; |