mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 13:09:42 +00:00
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>
This commit is contained in:
parent
d66adf0c85
commit
4c9b30db67
@ -66,6 +66,7 @@ function Buffer(subject, encoding) {
|
|||||||
'size: 0x' + kMaxLength.toString(16) + ' bytes');
|
'size: 0x' + kMaxLength.toString(16) + ' bytes');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.parent = null;
|
||||||
if (this.length <= (Buffer.poolSize >>> 1) && this.length > 0) {
|
if (this.length <= (Buffer.poolSize >>> 1) && this.length > 0) {
|
||||||
if (this.length > poolSize - poolOffset)
|
if (this.length > poolSize - poolOffset)
|
||||||
createPool();
|
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)
|
// toString(encoding, start=0, end=buffer.length)
|
||||||
Buffer.prototype.toString = function(encoding, start, end) {
|
Buffer.prototype.toString = function(encoding, start, end) {
|
||||||
var loweredCase = false;
|
var loweredCase = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user