mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Avoid double cloning for the common case in _.omit.
This commit is contained in:
10
lodash.js
10
lodash.js
@@ -13460,16 +13460,16 @@
|
|||||||
if (object == null) {
|
if (object == null) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
var bitmask = CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG;
|
var isDeep = false;
|
||||||
paths = arrayMap(paths, function(path) {
|
paths = arrayMap(paths, function(path) {
|
||||||
path = castPath(path, object);
|
path = castPath(path, object);
|
||||||
bitmask |= (path.length > 1 ? CLONE_DEEP_FLAG : 0);
|
isDeep || (isDeep = path.length > 1);
|
||||||
return path;
|
return path;
|
||||||
});
|
});
|
||||||
|
|
||||||
copyObject(object, getAllKeysIn(object), result);
|
copyObject(object, getAllKeysIn(object), result);
|
||||||
result = baseClone(result, bitmask);
|
if (isDeep) {
|
||||||
|
result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG);
|
||||||
|
}
|
||||||
var length = paths.length;
|
var length = paths.length;
|
||||||
while (length--) {
|
while (length--) {
|
||||||
baseUnset(result, paths[length]);
|
baseUnset(result, paths[length]);
|
||||||
|
|||||||
Reference in New Issue
Block a user