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 Aug 14, 2024
1 parent fe793a6 commit f7f7b0c
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 f7f7b0c

Please sign in to comment.