Skip to content

Commit

Permalink
buffer: optimize for common encodings
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Aug 11, 2024
1 parent 298ff4f commit e6514d4
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 e6514d4

Please sign in to comment.