fs: pool size coincide with ReadStream bufferSize
pool size of file reading in ReadableStream can be adjustable with a bufferSize option.
This commit is contained in:
parent
93591a2a88
commit
829f96bada
@ -38,7 +38,6 @@ var Readable = Stream.Readable;
|
|||||||
var Writable = Stream.Writable;
|
var Writable = Stream.Writable;
|
||||||
|
|
||||||
var kMinPoolSpace = 128;
|
var kMinPoolSpace = 128;
|
||||||
var kPoolSize = 40 * 1024;
|
|
||||||
|
|
||||||
var O_APPEND = constants.O_APPEND || 0;
|
var O_APPEND = constants.O_APPEND || 0;
|
||||||
var O_CREAT = constants.O_CREAT || 0;
|
var O_CREAT = constants.O_CREAT || 0;
|
||||||
@ -1370,8 +1369,8 @@ fs.realpath = function realpath(p, cache, cb) {
|
|||||||
|
|
||||||
var pool;
|
var pool;
|
||||||
|
|
||||||
function allocNewPool() {
|
function allocNewPool(poolSize) {
|
||||||
pool = new Buffer(kPoolSize);
|
pool = new Buffer(poolSize);
|
||||||
pool.used = 0;
|
pool.used = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1468,7 +1467,7 @@ ReadStream.prototype._read = function(n, cb) {
|
|||||||
// discard the old pool. Can't add to the free list because
|
// discard the old pool. Can't add to the free list because
|
||||||
// users might have refernces to slices on it.
|
// users might have refernces to slices on it.
|
||||||
pool = null;
|
pool = null;
|
||||||
allocNewPool();
|
allocNewPool(this._readableState.bufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab another reference to the pool in the case that while we're
|
// Grab another reference to the pool in the case that while we're
|
||||||
|
Loading…
x
Reference in New Issue
Block a user