Skip to content

Commit e6e7f39

Browse files
kylo5abyUlisesGascon
authored andcommitted
util: improve performance of normalizeEncoding
PR-URL: #50721 Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
1 parent 68e7d49 commit e6e7f39

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/internal/util.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,13 @@ function slowCases(enc) {
219219
case 4:
220220
if (enc === 'UTF8') return 'utf8';
221221
if (enc === 'ucs2' || enc === 'UCS2') return 'utf16le';
222-
enc = `${enc}`.toLowerCase();
222+
enc = StringPrototypeToLowerCase(enc);
223223
if (enc === 'utf8') return 'utf8';
224224
if (enc === 'ucs2') return 'utf16le';
225225
break;
226226
case 3:
227227
if (enc === 'hex' || enc === 'HEX' ||
228-
`${enc}`.toLowerCase() === 'hex')
228+
StringPrototypeToLowerCase(enc) === 'hex')
229229
return 'hex';
230230
break;
231231
case 5:
@@ -234,7 +234,7 @@ function slowCases(enc) {
234234
if (enc === 'UTF-8') return 'utf8';
235235
if (enc === 'ASCII') return 'ascii';
236236
if (enc === 'UCS-2') return 'utf16le';
237-
enc = `${enc}`.toLowerCase();
237+
enc = StringPrototypeToLowerCase(enc);
238238
if (enc === 'utf-8') return 'utf8';
239239
if (enc === 'ascii') return 'ascii';
240240
if (enc === 'ucs-2') return 'utf16le';
@@ -244,23 +244,23 @@ function slowCases(enc) {
244244
if (enc === 'latin1' || enc === 'binary') return 'latin1';
245245
if (enc === 'BASE64') return 'base64';
246246
if (enc === 'LATIN1' || enc === 'BINARY') return 'latin1';
247-
enc = `${enc}`.toLowerCase();
247+
enc = StringPrototypeToLowerCase(enc);
248248
if (enc === 'base64') return 'base64';
249249
if (enc === 'latin1' || enc === 'binary') return 'latin1';
250250
break;
251251
case 7:
252252
if (enc === 'utf16le' || enc === 'UTF16LE' ||
253-
`${enc}`.toLowerCase() === 'utf16le')
253+
StringPrototypeToLowerCase(enc) === 'utf16le')
254254
return 'utf16le';
255255
break;
256256
case 8:
257257
if (enc === 'utf-16le' || enc === 'UTF-16LE' ||
258-
`${enc}`.toLowerCase() === 'utf-16le')
258+
StringPrototypeToLowerCase(enc) === 'utf-16le')
259259
return 'utf16le';
260260
break;
261261
case 9:
262262
if (enc === 'base64url' || enc === 'BASE64URL' ||
263-
`${enc}`.toLowerCase() === 'base64url')
263+
StringPrototypeToLowerCase(enc) === 'base64url')
264264
return 'base64url';
265265
break;
266266
default:

0 commit comments

Comments
 (0)