|
|
@ -80,15 +80,6 @@ SlowBuffer.prototype.write = function (string, offset, encoding) { |
|
|
|
|
|
|
|
|
|
|
|
// Buffer
|
|
|
|
var POOLSIZE = 8*1024; |
|
|
|
var pool; |
|
|
|
|
|
|
|
|
|
|
|
function allocPool () { |
|
|
|
pool = new SlowBuffer(POOLSIZE); |
|
|
|
pool.used = 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function Buffer (subject, encoding, offset) { |
|
|
|
if (!(this instanceof Buffer)) { |
|
|
@ -127,7 +118,7 @@ function Buffer (subject, encoding, offset) { |
|
|
|
|
|
|
|
this.length = length; |
|
|
|
|
|
|
|
if (length > POOLSIZE) { |
|
|
|
if (length > Buffer.poolSize) { |
|
|
|
// Big buffer, just alloc one.
|
|
|
|
var parent = new SlowBuffer(subject, encoding); |
|
|
|
Object.defineProperty(this, "parent", { enumerable: false, |
|
|
@ -167,6 +158,14 @@ function Buffer (subject, encoding, offset) { |
|
|
|
|
|
|
|
exports.Buffer = Buffer; |
|
|
|
|
|
|
|
Buffer.poolSize = 8*1024; |
|
|
|
var pool; |
|
|
|
|
|
|
|
function allocPool () { |
|
|
|
pool = new SlowBuffer(Buffer.poolSize); |
|
|
|
pool.used = 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Static methods
|
|
|
|
Buffer.isBuffer = function isBuffer(b) { |
|
|
|