From 6c6064699ae9c3cb6c56e869c707dbb12ea755f9 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Wed, 4 Dec 2013 02:11:23 -0800 Subject: [PATCH] apply Uint8Array speed optimization in Firefox MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit In Firefox the buffer is not `instanceof Uint8Array` so let’s use Buffer.isBuffer instead --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index b5e352b..7ddec77 100644 --- a/index.js +++ b/index.js @@ -53,9 +53,9 @@ function Buffer (subject, encoding) { buf = augment(new Uint8Array(length)) } - if (subject instanceof Uint8Array) { + if (Buffer.isBuffer(subject)) { // Speed optimization -- use set if we're copying from a Uint8Array - buf.set(subject, 0) + buf.set(subject) } else if (isArrayIsh(subject)) { // Treat array-ish objects as a byte array. for (var i = 0; i < length; i++) { -- 2.34.1