From 285d8c658914d43cb39bacbde1ae62d8f6be25cf Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 29 Mar 2012 01:31:12 +0200 Subject: [PATCH] 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. --- lib/buffer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/buffer.js b/lib/buffer.js index a0210b9b876..c23adb502e4 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -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.