Skip to content

Commit 285d8c6

Browse files
committed
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.
1 parent 67fc1da commit 285d8c6

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/buffer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ function Buffer(subject, encoding, offset) {
250250
this.parent = pool;
251251
this.offset = pool.used;
252252
pool.used += this.length;
253+
if (pool.used & 7) pool.used = (pool.used + 8) & ~7;
253254
}
254255

255256
// Treat array-ish objects as a byte array.

0 commit comments

Comments
 (0)