From 21c2c01ebed902c70763bb9319c3ec48c4cb5284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 5 Jun 2023 10:52:40 +0200 Subject: perf: optimize RegExp usage in JS (#19364) Towards https://github.com/denoland/deno/issues/19330 Shows about 1% improvement in the HTTP benchmark. --- ext/websocket/01_websocket.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ext/websocket/01_websocket.js') 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( -- cgit v1.2.3