Skip to content

Commit 173747c

Browse files
committed
perf: labelToName fast path for UTF-8
1 parent b23bea6 commit 173747c

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

fallback/encoding.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ const uppercasePrefixes = new Set(['utf', 'iso', 'koi', 'euc', 'ibm', 'gbk'])
295295
// https://encoding.spec.whatwg.org/#names-and-labels
296296
export function labelToName(label) {
297297
const enc = normalizeEncoding(label)
298+
if (enc === 'utf-8') return 'UTF-8' // fast path
298299
if (!enc) return enc
299300
if (uppercasePrefixes.has(enc.slice(0, 3))) return enc.toUpperCase()
300301
if (enc === 'big5') return 'Big5'

0 commit comments

Comments
 (0)