0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-29 08:58:01 -04:00

perf(fetch): optimize fillHeaders() key iteration (#12287)

Reduces self-time by ~70x (~70ms => ~1ms on 1M iters)

for...in filtered by hasOwnProperty yields the same set of keys as Object.keys()
This commit is contained in:
Aaron O'Mullan 2021-10-01 12:17:16 +02:00 committed by GitHub
parent 5065c7bcd9
commit f68825eda0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,7 +29,7 @@
ArrayPrototypeJoin,
ArrayPrototypeSplice,
ArrayPrototypeFilter,
ObjectKeys,
ObjectPrototypeHasOwnProperty,
ObjectEntries,
RegExpPrototypeTest,
Symbol,
@ -76,7 +76,10 @@
appendHeader(headers, header[0], header[1]);
}
} else {
for (const key of ObjectKeys(object)) {
for (const key in object) {
if (!ObjectPrototypeHasOwnProperty(object, key)) {
continue;
}
appendHeader(headers, key, object[key]);
}
}