From 82a7c01898257edb9d9399735bac823ace630b30 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 13 Sep 2012 00:04:53 -0700 Subject: [PATCH] Simplify "underscore" build of `_.clone`. Former-commit-id: 32975bb5966f1ded4f007eb76dcf2d4677478e7d --- build.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/build.js b/build.js index 446cf3d16..81bf00bde 100755 --- a/build.js +++ b/build.js @@ -826,23 +826,16 @@ // remove `deep` clone functionality source = source.replace(/( +)function clone[\s\S]+?\n\1}/, [ ' function clone(value) {', - ' if (value == null) {', - ' return value;', - ' }', - ' var isObj = objectTypes[typeof value];', - ' if (isObj && value.clone && isFunction(value.clone)) {', - ' return value.clone(deep);', - ' }', - ' if (isObj) {', + ' if (value && objectTypes[typeof value]) {', ' var className = toString.call(value);', ' if (!cloneableClasses[className] || (noArgsClass && isArguments(value))) {', - ' return value;', + ' return value', ' }', - ' var isArr = className == arrayClass;', + ' return className == arrayClass', + ' ? slice.call(value)', + ' : extend({}, value)', ' }', - ' return isObj', - ' ? (isArr ? slice.call(value) : extend({}, value))', - ' : value;', + ' return value', ' }' ].join('\n')); }