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 Aug 13, 2024
1 parent d0f5943 commit b00102e
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 @@ -1108,8 +1108,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 b00102e

Please sign in to comment.