summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKang-Hao Kenny <kanghao.lkh@alibaba-inc.com>2014-09-19 23:14:37 +0800
committerTrevor Norris <trev.norris@gmail.com>2014-09-19 17:11:10 -0700
commit4c9b30db675ba3094a733e2691e968b658105334 (patch)
tree4771f08a4bcf211cfe89b7fbfe20653361e0a7ac
parentd66adf0c85fa8b26c7f72c5bd030fbcb79dbb0bb (diff)
downloadnodejs-4c9b30db675ba3094a733e2691e968b658105334.tar.gz
nodejs-4c9b30db675ba3094a733e2691e968b658105334.tar.bz2
nodejs-4c9b30db675ba3094a733e2691e968b658105334.zip
buffer: improve Buffer constructor
Increase the performance of new Buffer construction by initializing all properties before SetIndexedPropertiesToExternalArrayData call. Reviewed-by: Trevor Norris <trev.norris@gmail.com>
-rw-r--r--lib/buffer.js6
1 files changed, 1 insertions, 5 deletions
diff --git a/lib/buffer.js b/lib/buffer.js
index bd69a9720..adb551a9e 100644
--- a/lib/buffer.js
+++ b/lib/buffer.js
@@ -66,6 +66,7 @@ function Buffer(subject, encoding) {
'size: 0x' + kMaxLength.toString(16) + ' bytes');
}
+ this.parent = null;
if (this.length <= (Buffer.poolSize >>> 1) && this.length > 0) {
if (this.length > poolSize - poolOffset)
createPool();
@@ -217,11 +218,6 @@ Buffer.byteLength = function(str, enc) {
};
-// pre-set for values that may exist in the future
-Buffer.prototype.length = undefined;
-Buffer.prototype.parent = undefined;
-
-
// toString(encoding, start=0, end=buffer.length)
Buffer.prototype.toString = function(encoding, start, end) {
var loweredCase = false;