mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 18:07:49 +00:00
Use Buffer.allocUnsafe when available.
This commit is contained in:
@@ -1470,6 +1470,7 @@
|
|||||||
var Buffer = moduleExports ? context.Buffer : undefined,
|
var Buffer = moduleExports ? context.Buffer : undefined,
|
||||||
Symbol = context.Symbol,
|
Symbol = context.Symbol,
|
||||||
Uint8Array = context.Uint8Array,
|
Uint8Array = context.Uint8Array,
|
||||||
|
allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
|
||||||
defineProperty = Object.defineProperty,
|
defineProperty = Object.defineProperty,
|
||||||
getPrototype = overArg(Object.getPrototypeOf, Object),
|
getPrototype = overArg(Object.getPrototypeOf, Object),
|
||||||
iteratorSymbol = Symbol ? Symbol.iterator : undefined,
|
iteratorSymbol = Symbol ? Symbol.iterator : undefined,
|
||||||
@@ -4424,7 +4425,9 @@
|
|||||||
if (isDeep) {
|
if (isDeep) {
|
||||||
return buffer.slice();
|
return buffer.slice();
|
||||||
}
|
}
|
||||||
var result = new buffer.constructor(buffer.length);
|
var length = buffer.length,
|
||||||
|
result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
|
||||||
|
|
||||||
buffer.copy(result);
|
buffer.copy(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user