Skip to content

Commit

Permalink
Fix serializedobject append for excessively large bytes length
Browse files Browse the repository at this point in the history
  • Loading branch information
wltsmrz committed May 14, 2015
1 parent e66978f commit 6c68f26
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/serializedobject.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,9 @@ SerializedObject.prototype.append = function(bytes) {
// Make sure both buffer and bytes are Array. Either could potentially be a
// Buffer.
if (Array.isArray(this.buffer) && Array.isArray(bytes)) {
// Array::concat is horribly slow where buffer length is 100 kbytes + One
// transaction with 1100 affected nodes took around 23 seconds to convert
// from json to bytes.
Array.prototype.push.apply(this.buffer, bytes);
for (var i = 0; i < bytes.length; i++) {
this.buffer.push(bytes[i]);
}
} else {
this.buffer = this.buffer.concat(bytes);
}
Expand Down

0 comments on commit 6c68f26

Please sign in to comment.