Warning : mutating the [[Prototype]] of an object
The code base has 3 statements around the allocate(that, length) function use the '.proto =' assignment which makes FireFox 45.0 (openSUSE 42.1) claims :
mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create.
Please refer to the page : http://stackoverflow.com/questions/23807805/why-is-mutating-the-prototype-of-an-object-bad-for-performance for more explanation.
Based on the performance test page : http://jsperf.com/proto-vs-object-create2, by the use of the '.proto =' assignment is 32% slower than Object.create().
I change the code personally as : ` if (Buffer.TYPED_ARRAY_SUPPORT) { // Buffer.prototype.proto = Uint8Array.prototype // Buffer.proto = Uint8Array Buffer.prototype = Object.create(Uint8Array.prototype) Buffer = Object.create(Uint8Array) }
function allocate (that, length) {
if (Buffer.TYPED_ARRAY_SUPPORT) {
// Return an augmented Uint8Array instance, for best performance
that = Buffer._augment(new Uint8Array(length))
// that.proto = Buffer.prototype
that = Object.create(Buffer.prototype)
} else {
// Fallback: Return an object instance of the Buffer class
that.length = length
that._isBuffer = true
}
var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1 if (fromPool) that.parent = rootParent
return that } `
Please verify the changes are appropriate or not.
Thank you all.
I've applied these changes and the module stopped working.
Sorry, I use XHR for streaming now, but as I recall it works for me in the day that I post this issue and use the solution for a while. Since I took another solution for my project, this package is removed already thus I can't re-produce this again.
Sorry ...