summaryrefslogtreecommitdiff
path: root/ext/websocket/01_websocket.js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-06-05 10:52:40 +0200
committerGitHub <noreply@github.com>2023-06-05 10:52:40 +0200
commit21c2c01ebed902c70763bb9319c3ec48c4cb5284 (patch)
tree82f01c418fc9abfb39aa370b3f3a6af820b10abb /ext/websocket/01_websocket.js
parentadf41edda12a26a84cb8b4252404aae2a9e7ae03 (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/websocket/01_websocket.js')
-rw-r--r--ext/websocket/01_websocket.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/websocket/01_websocket.js b/ext/websocket/01_websocket.js
index f7dd516ff..c4c686b9c 100644
--- a/ext/websocket/01_websocket.js
+++ b/ext/websocket/01_websocket.js
@@ -33,7 +33,7 @@ const {
ObjectDefineProperties,
ObjectPrototypeIsPrototypeOf,
PromisePrototypeThen,
- RegExpPrototypeTest,
+ RegExpPrototypeExec,
SafeSet,
SetPrototypeGetSize,
// TODO(lucacasonato): add SharedArrayBuffer to primordials
@@ -256,7 +256,8 @@ class WebSocket extends EventTarget {
if (
ArrayPrototypeSome(
protocols,
- (protocol) => !RegExpPrototypeTest(HTTP_TOKEN_CODE_POINT_RE, protocol),
+ (protocol) =>
+ RegExpPrototypeExec(HTTP_TOKEN_CODE_POINT_RE, protocol) === null,
)
) {
throw new DOMException(