Browse Source

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.
v0.9.1-release
Ben Noordhuis 13 years ago
parent
commit
285d8c6589
  1. 1
      lib/buffer.js

1
lib/buffer.js

@ -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.

Loading…
Cancel
Save