defineProperty is slow, don't use it for fastbuffer
This commit is contained in:
parent
d3fcd1c75a
commit
17ba821e60
@ -91,12 +91,8 @@ function Buffer (subject, encoding, offset) {
|
||||
// Are we slicing?
|
||||
if (typeof offset === 'number') {
|
||||
this.length = encoding;
|
||||
Object.defineProperty(this, "parent", { enumerable: false,
|
||||
value: subject,
|
||||
writable: false });
|
||||
Object.defineProperty(this, "offset", { enumerable: false,
|
||||
value: offset,
|
||||
writable: false });
|
||||
this.parent = subject;
|
||||
this.offset = offset;
|
||||
} else {
|
||||
// Find the length
|
||||
switch (type = typeof subject) {
|
||||
@ -120,22 +116,14 @@ function Buffer (subject, encoding, offset) {
|
||||
|
||||
if (length > Buffer.poolSize) {
|
||||
// Big buffer, just alloc one.
|
||||
var parent = new SlowBuffer(subject, encoding);
|
||||
Object.defineProperty(this, "parent", { enumerable: false,
|
||||
value: parent,
|
||||
writable: false });
|
||||
Object.defineProperty(this, "offset", { enumerable: false,
|
||||
value: 0,
|
||||
writable: false });
|
||||
this.parent = new SlowBuffer(subject, encoding);
|
||||
this.offset = 0;
|
||||
|
||||
} else {
|
||||
// Small buffer.
|
||||
if (!pool || pool.length - pool.used < length) allocPool();
|
||||
Object.defineProperty(this, "parent", { enumerable: false,
|
||||
value: pool,
|
||||
writable: false });
|
||||
Object.defineProperty(this, "offset", { enumerable: false,
|
||||
value: pool.used,
|
||||
writable: false });
|
||||
this.parent = pool;
|
||||
this.offset = pool.used;
|
||||
pool.used += length;
|
||||
|
||||
// Do we need to write stuff?
|
||||
|
Loading…
x
Reference in New Issue
Block a user