From 558a884d4132a2e5088833de6e096e32e78d5f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Mon, 26 Sep 2016 20:14:32 +0200 Subject: [PATCH] buffer: fix performance regression MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit V8 5.4 changed the way that the default constructor of derived classes is called. It introduced a significant performance regression in the buffer module for the creation of pooled buffers. This commit forces the definition back to how it was implicitly before. Ref: https://bugs.chromium.org/p/v8/issues/detail?id=4890 PR-URL: https://github.com/nodejs/node/pull/8754 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Trevor Norris Reviewed-By: Ilkka Myller Reviewed-By: Fedor Indutny Reviewed-By: Johan Bergström --- lib/buffer.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/buffer.js b/lib/buffer.js index 876bdbe1cfd..86aa2e512ea 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -6,7 +6,11 @@ const { isArrayBuffer, isSharedArrayBuffer } = process.binding('util'); const bindingObj = {}; const internalUtil = require('internal/util'); -class FastBuffer extends Uint8Array {} +class FastBuffer extends Uint8Array { + constructor(arg1, arg2, arg3) { + super(arg1, arg2, arg3); + } +} FastBuffer.prototype.constructor = Buffer; Buffer.prototype = FastBuffer.prototype;