buffer: default to UTF8 in byteLength()
If an undefined encoding is passed to byteLength(), assume that it is UTF8 immediately. This yields a small speedup, as it prevents string operations on the encoding argument. PR-URL: https://github.com/nodejs/node/pull/4010 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
This commit is contained in:
parent
a881b53954
commit
93739f48ff
@ -272,6 +272,7 @@ function byteLength(string, encoding) {
|
||||
|
||||
case 'utf8':
|
||||
case 'utf-8':
|
||||
case undefined:
|
||||
return binding.byteLengthUtf8(string);
|
||||
|
||||
case 'ucs2':
|
||||
|
Loading…
x
Reference in New Issue
Block a user