Open
Description
Currently we have an optimization which turns off zero fill of ArrayBuffers
during allocation through the Buffer.allocUnsafeSlow
method:
let zeroFill = getZeroFillToggle();
function createUnsafeBuffer(size) {
zeroFill[0] = 0;
try {
return new FastBuffer(size);
} finally {
zeroFill[0] = 1;
}
}
This can be used to quickly allocate ArrayBuffer
s:
const arrayBuffer = Buffer.allocateUnsafeSlow(size).buffer
The problem is that this does not allow allocating ArrayBuffer
s with a specified maxByteLength
:
const arrayBuffer = new ArrayBuffer(size, { maxByteLength: capacity })
Could we add some way to perform the allocation similarly? Maybe an option to Buffer.allocateUnsafeSlow
?