Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

string_decoder: fix performance regression #5134

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/string_decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ StringDecoder.prototype.write = function(buffer) {
var charReceived = this.charReceived;
var surrogateSize = this.surrogateSize;
var encoding = this.encoding;
var charCode;
// if our last write ended with an incomplete multibyte character
while (charLength) {
// determine how many remaining bytes this buffer has to offer for this char
Expand Down Expand Up @@ -96,7 +97,7 @@ StringDecoder.prototype.write = function(buffer) {
charStr = charBuffer.toString(encoding, 0, charLength);

// CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
const charCode = charStr.charCodeAt(charStr.length - 1);
charCode = charStr.charCodeAt(charStr.length - 1);
if (charCode >= 0xD800 && charCode <= 0xDBFF) {
charLength += surrogateSize;
charStr = '';
Expand Down Expand Up @@ -129,7 +130,7 @@ StringDecoder.prototype.write = function(buffer) {
charStr += buffer.toString(encoding, 0, end);

end = charStr.length - 1;
const charCode = charStr.charCodeAt(end);
charCode = charStr.charCodeAt(end);
// CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
if (charCode >= 0xD800 && charCode <= 0xDBFF) {
charLength += surrogateSize;
Expand Down