Skip to content

Commit

Permalink
buffer: optimize for common encodings
Browse files Browse the repository at this point in the history
PR-URL: #54319
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Bryan English <[email protected]>
  • Loading branch information
ronag authored and targos committed Oct 2, 2024
1 parent 27da75a commit f5f40c8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1106,8 +1106,10 @@ Buffer.prototype.write = function write(string, offset, length, encoding) {
}
}

if (!encoding)
if (!encoding || encoding === 'utf8')
return this.utf8Write(string, offset, length);
if (encoding === 'ascii')
return this.asciiWrite(string, offset, length);

const ops = getEncodingOps(encoding);
if (ops === undefined)
Expand Down

0 comments on commit f5f40c8

Please sign in to comment.