Skip to content

Commit

Permalink
buffer: align fast buffers on 8 byte boundary
Browse files Browse the repository at this point in the history
Prevents alignment issues when people create a typed array from a buffer.
Unaligned loads or stores are less efficent and (on some architectures) unsafe.
  • Loading branch information
bnoordhuis committed Mar 28, 2012
1 parent 67fc1da commit 285d8c6
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ function Buffer(subject, encoding, offset) {
this.parent = pool;
this.offset = pool.used;
pool.used += this.length;
if (pool.used & 7) pool.used = (pool.used + 8) & ~7;
}

// Treat array-ish objects as a byte array.
Expand Down

0 comments on commit 285d8c6

Please sign in to comment.