Skip to content

Commit 12d1c3c

Browse files
committed
refactor: more compact table, -1% size for encoding-lite
1 parent 88a9fb5 commit 12d1c3c

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

fallback/single-byte.encodings.js

Lines changed: 11 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fallback/single-byte.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ export const assertEncoding = (encoding) => {
1010
throw new RangeError('Unsupported encoding')
1111
}
1212

13+
const f = 0xff_fd
14+
1315
function getEncoding(encoding) {
1416
assertEncoding(encoding)
1517
if (encoding === xUserDefined) {
1618
return Array.from({ length: 128 }, (_, i) => 0xf7_80 + i)
1719
}
1820

1921
let prev = 127
20-
return encodings[encoding].map((x) => (prev += x)) // eslint-disable-line no-return-assign
22+
return encodings[encoding].map((x) => x === f ? x : (prev += x)) // eslint-disable-line no-return-assign
2123
}
2224

2325
const mappers = new Map()

0 commit comments

Comments
 (0)