From 34396dbbecd5eb41c9b396fc720982a5d0c88eae Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 16 Jul 2013 23:57:23 -0700 Subject: [PATCH] Simplify type checks in `_.isEqual`. Former-commit-id: a1aeb5aeab6ef30c6f9377f5498da4eb6d112bc3 --- build.js | 6 +++--- lodash.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.js b/build.js index a65315a9c..913ba8a70 100644 --- a/build.js +++ b/build.js @@ -266,7 +266,7 @@ 'escapeHtmlChar': ['htmlEscapes'], 'htmlUnescapes': ['htmlEscapes'], 'isArray': ['reNative'], - 'isEqual': ['indicatorObject'], + 'isEqual': ['indicatorObject', 'objectTypes'], 'isObject': ['objectTypes'], 'isPlainObject': ['reNative'], 'isRegExp': ['objectTypes'], @@ -3320,8 +3320,8 @@ ' otherType = typeof b;', '', ' if (a === a &&', - " (!a || (type != 'function' && type != 'object')) &&", - " (!b || (otherType != 'function' && otherType != 'object'))) {", + " !(a && objectTypes[type]) &&", + " !(b && objectTypes[otherType])) {", ' return false;', ' }', ' if (a == null || b == null) {', diff --git a/lodash.js b/lodash.js index 71677b2da..7bb007547 100644 --- a/lodash.js +++ b/lodash.js @@ -1934,8 +1934,8 @@ // exit early for unlike primitive values if (a === a && - (!a || (type != 'function' && type != 'object')) && - (!b || (otherType != 'function' && otherType != 'object'))) { + !(a && objectTypes[type]) && + !(b && objectTypes[otherType])) { return false; } // exit early for `null` and `undefined`, avoiding ES3's Function#call behavior