Skip to content

Commit

Permalink
perf: improve isomorphic decode performance
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Nov 30, 2022
1 parent 232905f commit b1f2fc8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/fetch/util.js
Expand Up @@ -871,13 +871,13 @@ function isomorphicDecode (input) {
// 1. To isomorphic decode a byte sequence input, return a string whose code point
// length is equal to input’s length and whose code points have the same values
// as the values of input’s bytes, in the same order.
let output = ''

for (let i = 0; i < input.length; i++) {
output += String.fromCharCode(input[i])
// In JavaScript, argument length limited to 65536
if (input.length > 65536) {
return input.reduce((previous, current) => previous + String.fromCharCode(current), '')
}

return output
return String.fromCharCode(...input)
}

/**
Expand Down

0 comments on commit b1f2fc8

Please sign in to comment.