Skip to content

Commit

Permalink
refactor(ext/fetch): avoid extra headers copy in .clone (denoland#16130)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosc90 authored Oct 3, 2022
1 parent 7a77672 commit d13c88e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
11 changes: 5 additions & 6 deletions ext/fetch/23_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
ObjectKeys,
ObjectPrototypeIsPrototypeOf,
RegExpPrototypeTest,
SafeArrayIterator,
Symbol,
SymbolFor,
TypeError,
Expand Down Expand Up @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions ext/fetch/23_response.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit d13c88e

Please sign in to comment.