mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05: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:
parent
2f2302ed70
commit
774302b9bb
1 changed files with 5 additions and 2 deletions
|
@ -29,7 +29,7 @@
|
||||||
ArrayPrototypeJoin,
|
ArrayPrototypeJoin,
|
||||||
ArrayPrototypeSplice,
|
ArrayPrototypeSplice,
|
||||||
ArrayPrototypeFilter,
|
ArrayPrototypeFilter,
|
||||||
ObjectKeys,
|
ObjectPrototypeHasOwnProperty,
|
||||||
ObjectEntries,
|
ObjectEntries,
|
||||||
RegExpPrototypeTest,
|
RegExpPrototypeTest,
|
||||||
Symbol,
|
Symbol,
|
||||||
|
@ -76,7 +76,10 @@
|
||||||
appendHeader(headers, header[0], header[1]);
|
appendHeader(headers, header[0], header[1]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (const key of ObjectKeys(object)) {
|
for (const key in object) {
|
||||||
|
if (!ObjectPrototypeHasOwnProperty(object, key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
appendHeader(headers, key, object[key]);
|
appendHeader(headers, key, object[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue