Avoid double cloning for the common case in _.omit.

This commit is contained in:
John-David Dalton
2016-11-15 18:18:19 -08:00
parent 9a02bd5fc7
commit 5bc9e6b8bd

View File

@@ -13460,16 +13460,16 @@
if (object == null) {
return result;
}
var bitmask = CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG;
var isDeep = false;
paths = arrayMap(paths, function(path) {
path = castPath(path, object);
bitmask |= (path.length > 1 ? CLONE_DEEP_FLAG : 0);
isDeep || (isDeep = path.length > 1);
return path;
});
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;
while (length--) {
baseUnset(result, paths[length]);