Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 93739f4

Browse filesBrowse files
tomgcocjihrig
authored andcommitted
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: #4010 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
1 parent a881b53 commit 93739f4
Copy full SHA for 93739f4

File tree

Expand file treeCollapse file tree

1 file changed

+1
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+1
-0
lines changed
Open diff view settings
Collapse file

‎lib/buffer.js‎

Copy file name to clipboardExpand all lines: lib/buffer.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ function byteLength(string, encoding) {
272272

273273
case 'utf8':
274274
case 'utf-8':
275+
case undefined:
275276
return binding.byteLengthUtf8(string);
276277

277278
case 'ucs2':

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.