From 2dda6be7991fc6809eedca4dc51935a178c63745 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sat, 4 Sep 2010 20:58:51 -0700 Subject: [PATCH] Fast Buffer safe constructor --- lib/buffer.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/buffer.js b/lib/buffer.js index 73899ba..72a82c0 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -91,6 +91,10 @@ function allocPool () { function Buffer (subject, encoding, legacy, slice_legacy) { + if (!(this instanceof Buffer)) { + return new Buffer(subject, encoding, legacy, slice_legacy); + } + var length, type; // Are we slicing? -- 2.7.4