function fromString(string, encoding) {
let length;
if (typeof encoding !== 'string' || encoding.length === 0) {
if (string.length === 0)
return new FastBuffer();
encoding = 'utf8';
length = byteLengthUtf8(string);
} else {
length = byteLength(string, encoding, true);
if (length === -1)
throw new ERR_UNKNOWN_ENCODING(encoding);
if (string.length === 0)
return new FastBuffer();
}
if (length >= (Buffer.poolSize >>> 1))
return createFromString(string, encoding);
...
}
在Node.js缓冲区模块中。
Buffer.poolSize为8kb。
我认为length >= Buffer.poolSize
可以,
为什么代码是length >= (Buffer.poolSize >>> 1)
?