Skip to content

Commit f7f7b0c

Browse files
ronagtargos
authored andcommitted
buffer: optimize for common encodings
PR-URL: #54319 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Bryan English <bryan@bryanenglish.com>
1 parent fe793a6 commit f7f7b0c

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)