perf(fetch): optimize fillHeaders() key iteration
Reduces self-time by ~70x (~70ms => ~1ms on 1M iters)
for...in filtered by hasOwnProperty yields the same set of keys as Object.keys()
ArrayPrototypeJoin,
ArrayPrototypeSplice,
ArrayPrototypeFilter,
- ObjectKeys,
+ ObjectPrototypeHasOwnProperty,
ObjectEntries,
RegExpPrototypeTest,
Symbol,
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]);
}
}
