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 and metcoder95 committed Nov 22, 2023
1 parent 0081a52 commit b0beb9d
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 b0beb9d

Please sign in to comment.