Skip to content

Commit

Permalink
perf(headers): if the guard is immutable (#2424)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsctx authored Nov 11, 2023
1 parent ecac429 commit 987b92e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/fetch/headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,12 @@ class Headers {
keys () {
webidl.brandCheck(this, Headers)

if (this[kGuard] === 'immutable') {
const value = this[kHeadersSortedMap]
return makeIterator(() => value, 'Headers',
'key')
}

return makeIterator(
() => [...this[kHeadersSortedMap].values()],
'Headers',
Expand All @@ -481,6 +487,12 @@ class Headers {
values () {
webidl.brandCheck(this, Headers)

if (this[kGuard] === 'immutable') {
const value = this[kHeadersSortedMap]
return makeIterator(() => value, 'Headers',
'value')
}

return makeIterator(
() => [...this[kHeadersSortedMap].values()],
'Headers',
Expand All @@ -491,6 +503,12 @@ class Headers {
entries () {
webidl.brandCheck(this, Headers)

if (this[kGuard] === 'immutable') {
const value = this[kHeadersSortedMap]
return makeIterator(() => value, 'Headers',
'key+value')
}

return makeIterator(
() => [...this[kHeadersSortedMap].values()],
'Headers',
Expand Down

0 comments on commit 987b92e

Please sign in to comment.