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 <yagiz@nizipli.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Bryan English <bryan@bryanenglish.com>
  • Loading branch information
ronag authored and targos committed Sep 26, 2024
1 parent 7d791ec commit cff11a2
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 cff11a2

Please sign in to comment.