From 6728ad4203d731e555dabf89ec6157f113454ce6 Mon Sep 17 00:00:00 2001 From: Kenta Moriuchi Date: Mon, 1 May 2023 22:30:02 +0900 Subject: fix(core): Use primordials for methods (#18839) I would like to get this change into Deno before merging https://github.com/denoland/deno_lint/pull/1152 --- ext/http/00_serve.js | 5 +++-- ext/http/01_http.js | 12 ++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'ext/http') diff --git a/ext/http/00_serve.js b/ext/http/00_serve.js index 33742e122..6aed08bdd 100644 --- a/ext/http/00_serve.js +++ b/ext/http/00_serve.js @@ -37,14 +37,15 @@ import { import { TcpConn } from "ext:deno_net/01_net.js"; const { ObjectPrototypeIsPrototypeOf, + PromisePrototypeCatch, SafeSet, SafeSetIterator, SetPrototypeAdd, SetPrototypeDelete, Symbol, TypeError, - Uint8ArrayPrototype, Uint8Array, + Uint8ArrayPrototype, } = primordials; const { @@ -667,7 +668,7 @@ async function serve(arg1, arg2) { if (req === 0xffffffff) { break; } - callback(req).catch((error) => { + PromisePrototypeCatch(callback(req), (error) => { // Abnormal exit console.error( "Terminating Deno.serve loop due to unexpected error", diff --git a/ext/http/01_http.js b/ext/http/01_http.js index 0048eedeb..f41a2beed 100644 --- a/ext/http/01_http.js +++ b/ext/http/01_http.js @@ -54,8 +54,9 @@ const { SetPrototypeDelete, StringPrototypeCharCodeAt, StringPrototypeIncludes, - StringPrototypeToLowerCase, StringPrototypeSplit, + StringPrototypeToLowerCase, + StringPrototypeToUpperCase, Symbol, SymbolAsyncIterator, TypeError, @@ -497,17 +498,20 @@ function buildCaseInsensitiveCommaValueFinder(checkText) { StringPrototypeToLowerCase(checkText), "", ), - (c) => [c.charCodeAt(0), c.toUpperCase().charCodeAt(0)], + (c) => [ + StringPrototypeCharCodeAt(c, 0), + StringPrototypeCharCodeAt(StringPrototypeToUpperCase(c), 0), + ], ); /** @type {number} */ let i; /** @type {number} */ let char; - /** @param value {string} */ + /** @param {string} value */ return function (value) { for (i = 0; i < value.length; i++) { - char = value.charCodeAt(i); + char = StringPrototypeCharCodeAt(value, i); skipWhitespace(value); if (hasWord(value)) { -- cgit v1.2.3