1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-12 00:54:02 -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, ObjectKeys,
ObjectPrototypeIsPrototypeOf, ObjectPrototypeIsPrototypeOf,
RegExpPrototypeTest, RegExpPrototypeTest,
SafeArrayIterator,
Symbol, Symbol,
SymbolFor, SymbolFor,
TypeError, TypeError,
@ -159,11 +158,11 @@
* @returns {InnerRequest} * @returns {InnerRequest}
*/ */
function cloneInnerRequest(request) { function cloneInnerRequest(request) {
const headerList = [ const headerList = ArrayPrototypeMap(
...new SafeArrayIterator( request.headerList,
ArrayPrototypeMap(request.headerList, (x) => [x[0], x[1]]), (x) => [x[0], x[1]],
), );
];
let body = null; let body = null;
if (request.body !== null) { if (request.body !== null) {
body = request.body.clone(); body = request.body.clone();

View file

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