1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 23:59:59 -05:00

refactor(ext/fetch): avoid extra headers copy in .clone (#16130)

This commit is contained in:
Marcos Casagrande 2022-10-03 13:34:13 +02:00 committed by GitHub
parent 7a7767262a
commit d13c88e70d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 11 deletions

View file

@ -35,7 +35,6 @@
ObjectKeys,
ObjectPrototypeIsPrototypeOf,
RegExpPrototypeTest,
SafeArrayIterator,
Symbol,
SymbolFor,
TypeError,
@ -159,11 +158,11 @@
* @returns {InnerRequest}
*/
function cloneInnerRequest(request) {
const headerList = [
...new SafeArrayIterator(
ArrayPrototypeMap(request.headerList, (x) => [x[0], x[1]]),
),
];
const headerList = ArrayPrototypeMap(
request.headerList,
(x) => [x[0], x[1]],
);
let body = null;
if (request.body !== null) {
body = request.body.clone();

View file

@ -97,11 +97,11 @@
*/
function cloneInnerResponse(response) {
const urlList = [...new SafeArrayIterator(response.urlList)];
const headerList = [
...new SafeArrayIterator(
ArrayPrototypeMap(response.headerList, (x) => [x[0], x[1]]),
),
];
const headerList = ArrayPrototypeMap(
response.headerList,
(x) => [x[0], x[1]],
);
let body = null;
if (response.body !== null) {
body = response.body.clone();