Skip to content

Commit f5f40c8

Browse files
ronagtargos
authored andcommittedOct 2, 2024
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 27da75a commit f5f40c8

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
@@ -1106,8 +1106,10 @@ Buffer.prototype.write = function write(string, offset, length, encoding) {
11061106
}
11071107
}
11081108

1109-
if (!encoding)
1109+
if (!encoding || encoding === 'utf8')
11101110
return this.utf8Write(string, offset, length);
1111+
if (encoding === 'ascii')
1112+
return this.asciiWrite(string, offset, length);
11111113

11121114
const ops = getEncodingOps(encoding);
11131115
if (ops === undefined)

0 commit comments

Comments
 (0)
Please sign in to comment.