buffer: align fast buffers on 8 byte boundary

Prevents alignment issues when people create a typed array from a buffer.
Unaligned loads or stores are less efficent and (on some architectures) unsafe.
pull/24503/head
Ben Noordhuis 2012-03-29 01:31:12 +02:00
parent 67fc1dafd0
commit 285d8c6589
1 changed files with 1 additions and 0 deletions

View File

@ -250,6 +250,7 @@ function Buffer(subject, encoding, offset) {
this.parent = pool; this.parent = pool;
this.offset = pool.used; this.offset = pool.used;
pool.used += this.length; pool.used += this.length;
if (pool.used & 7) pool.used = (pool.used + 8) & ~7;
} }
// Treat array-ish objects as a byte array. // Treat array-ish objects as a byte array.