mirror of
https://github.com/denoland/deno.git
synced 2024-12-23 15:49:44 -05:00
perf(fetch): optimize newInnerRequest blob url check (#12245)
Avoid "blob:" prefix check on requests built in the http module since those can never be blob objects Reduces cost of `newInnerRequest()` from 20ms to 0.1ms in my profiled run on ~2.5M reqs
This commit is contained in:
parent
ff3a17b72d
commit
9167f0c6bd
2 changed files with 5 additions and 3 deletions
|
@ -67,11 +67,12 @@
|
|||
* @param {string} url
|
||||
* @param {[string, string][]} headerList
|
||||
* @param {typeof __window.bootstrap.fetchBody.InnerBody} body
|
||||
* @param {boolean} maybeBlob
|
||||
* @returns
|
||||
*/
|
||||
function newInnerRequest(method, url, headerList = [], body = null) {
|
||||
function newInnerRequest(method, url, headerList, body, maybeBlob) {
|
||||
let blobUrlEntry = null;
|
||||
if (url.startsWith("blob:")) {
|
||||
if (maybeBlob && url.startsWith("blob:")) {
|
||||
blobUrlEntry = blobFromObjectUrl(url);
|
||||
}
|
||||
return {
|
||||
|
@ -236,7 +237,7 @@
|
|||
// 5.
|
||||
if (typeof input === "string") {
|
||||
const parsedURL = new URL(input, baseURL);
|
||||
request = newInnerRequest("GET", parsedURL.href, [], null);
|
||||
request = newInnerRequest("GET", parsedURL.href, [], null, true);
|
||||
} else { // 6.
|
||||
if (!(input instanceof Request)) throw new TypeError("Unreachable");
|
||||
request = input[_request];
|
||||
|
|
|
@ -103,6 +103,7 @@
|
|||
url,
|
||||
headersList,
|
||||
body !== null ? new InnerBody(body) : null,
|
||||
false,
|
||||
);
|
||||
const signal = abortSignal.newSignal();
|
||||
const request = fromInnerRequest(innerRequest, signal, "immutable");
|
||||
|
|
Loading…
Reference in a new issue