Add _.where fast path for the common use case or passing an object with one property.

Former-commit-id: dfb78f59ae22f3ccdd88d58cefdb8abcde58eda6
This commit is contained in:
John-David Dalton
2013-07-18 08:30:05 -07:00
parent bb49b0c16a
commit 3de0a16a9d
2 changed files with 21 additions and 8 deletions

View File

@@ -4762,10 +4762,20 @@
return object[func];
};
}
var props = keys(func);
var props = keys(func),
key = props[0],
a = func[key];
if (props.length == 1 && a === a && !isObject(a)) {
return function(object) {
var b = object[key];
return a === b && (a !== 0 || (1 / a == 1 / b));
};
}
return function(object) {
var length = props.length,
result = false;
while (length--) {
if (!(result = isEqual(object[props[length]], func[props[length]], indicatorObject))) {
break;