Skip to content

Commit ec8afa1

Browse files
committed
refactor: name a var
1 parent 845abe6 commit ec8afa1

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

fallback/encoding.util.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,28 @@ export function unfinishedBytes(u, len, enc) {
3636
// otherwise returns a prefix with no unfinished bytes
3737
export function mergePrefix(u, chunk, enc) {
3838
if (u.length === 0) return chunk
39+
const cl = chunk.length
3940
if (u.length < 3) {
4041
// No reason to bruteforce offsets, also it's possible this doesn't yet end the sequence
41-
const a = new Uint8Array(u.length + chunk.length)
42+
const a = new Uint8Array(u.length + cl)
4243
a.set(chunk)
43-
a.set(u, chunk.length)
44+
a.set(u, cl)
4445
return a
4546
}
4647

4748
// Slice off a small portion of u into prefix chunk so we can decode them separately without extending array size
48-
const t = new Uint8Array(chunk.length + 3) // We have 1-3 bytes and need 1-3 more bytes
49+
const t = new Uint8Array(cl + 3) // We have 1-3 bytes and need 1-3 more bytes
4950
t.set(chunk)
50-
t.set(u.subarray(0, 3), chunk.length)
51+
t.set(u.subarray(0, 3), cl)
5152

5253
// Stop at the first offset where unfinished bytes reaches 0 or fits into u
5354
// If that doesn't happen (u too short), just concat chunk and u completely (above)
5455
for (let i = 1; i <= 3; i++) {
55-
const unfinished = unfinishedBytes(t, chunk.length + i, enc) // 0-3
56+
const unfinished = unfinishedBytes(t, cl + i, enc) // 0-3
5657
if (unfinished <= i) {
5758
// Always reachable at 3, but we still need 'unfinished' value for it
5859
const add = i - unfinished // 0-3
59-
return add > 0 ? t.subarray(0, chunk.length + add) : chunk
60+
return add > 0 ? t.subarray(0, cl + add) : chunk
6061
}
6162
}
6263

0 commit comments

Comments
 (0)