Skip to content

Commit b00102e

Browse files
authored
buffer: optimize for common encodings
PR-URL: nodejs#54319 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Bryan English <[email protected]>
1 parent d0f5943 commit b00102e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/buffer.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1108,8 +1108,10 @@ Buffer.prototype.write = function write(string, offset, length, encoding) {
11081108
}
11091109
}
11101110

1111-
if (!encoding)
1111+
if (!encoding || encoding === 'utf8')
11121112
return this.utf8Write(string, offset, length);
1113+
if (encoding === 'ascii')
1114+
return this.asciiWrite(string, offset, length);
11131115

11141116
const ops = getEncodingOps(encoding);
11151117
if (ops === undefined)

0 commit comments

Comments
 (0)