From e94ca12f9f9f2881dd306ef470c34cecb661a655 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 26 Jul 2013 19:35:01 -0700 Subject: [PATCH] Add `getObject` and `releaseObject` to `setBindData`. Former-commit-id: d4152ccc078bfa64d62640d89b673057cf9f6a19 --- build.js | 21 +++++++++++++-------- build/pre-compile.js | 3 +++ dist/lodash.compat.js | 15 ++++++++------- dist/lodash.compat.min.js | 2 +- dist/lodash.js | 15 ++++++++------- dist/lodash.min.js | 4 ++-- lodash.js | 15 ++++++++------- 7 files changed, 43 insertions(+), 32 deletions(-) diff --git a/build.js b/build.js index 641bad19c..88cf5201c 100644 --- a/build.js +++ b/build.js @@ -226,7 +226,7 @@ 'noop': [], 'releaseArray': [], 'releaseObject': [], - 'setBindData': ['noop'], + 'setBindData': ['getObject', 'noop', 'releaseObject'], 'shimIsPlainObject': ['forIn', 'isArguments', 'isFunction', 'isNode'], 'shimKeys': ['createIterator'], 'slice': [], @@ -4049,13 +4049,6 @@ source = removeKeysOptimization(source); source = removeSupportNonEnumArgs(source); } - if (isExcluded('sortBy')) { - _.each([removeFromGetObject, removeFromReleaseObject], function(func) { - source = func(source, 'criteria'); - source = func(source, 'index'); - source = func(source, 'value'); - }); - } if (isExcluded('throttle')) { _.each(['leading', 'maxWait', 'trailing'], function(prop) { source = removeFromGetObject(source, prop); @@ -4075,6 +4068,18 @@ .replace(/,(?=\s*])/, ''); }); } + _.each([removeFromGetObject, removeFromReleaseObject], function(func) { + if (isExcluded('setBindData')) { + source = func(source, 'configurable'); + source = func(source, 'enumerable'); + source = func(source, 'writable'); + } + if (isExcluded('sortBy')) { + source = func(source, 'criteria'); + source = func(source, 'index'); + source = func(source, 'value'); + } + }); } // remove functions from the build diff --git a/build/pre-compile.js b/build/pre-compile.js index 00e0b9191..34fc80fc9 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -105,6 +105,7 @@ 'collect', 'compact', 'compose', + 'configurable', 'contains', 'countBy', 'createCallback', @@ -117,6 +118,7 @@ 'difference', 'drop', 'each', + 'enumerable', 'enumErrorProps', 'enumPrototypes', 'environment', @@ -249,6 +251,7 @@ 'window', 'without', 'wrap', + 'writable', 'zip', 'zipObject' ]; diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 250e8f26c..a40cf1684 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -321,7 +321,9 @@ 'array': null, 'bottom': '', 'cache': null, + 'configurable': false, 'criteria': null, + 'enumerable': false, 'false': false, 'firstArg': '', 'index': 0, @@ -341,7 +343,8 @@ 'true': false, 'undefined': false, 'useHas': false, - 'value': null + 'value': null, + 'writable': false }; } @@ -1512,12 +1515,10 @@ * @param {Mixed} value The value to set. */ var setBindData = !defineProperty ? noop : function(func, value) { - defineProperty(func, '__bindData__', { - 'configurable': false, - 'enumerable': false, - 'value': value, - 'writable': false - }); + var descriptor = getObject(); + descriptor.value = value; + defineProperty(func, '__bindData__', descriptor); + releaseObject(descriptor); }; /** diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index d15a61979..bb27cf21c 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -4,7 +4,7 @@ * Build: `lodash -o ./dist/lodash.compat.js` */ ;!function(n){function t(n,t,e){e=(e||0)-1;for(var r=n?n.length:0;++et||typeof n=="undefined")return 1;if(nt||typeof n=="undefined")return 1;if(ne?0:e);++rt||typeof n=="undefined")return 1;if(nt||typeof n=="undefined")return 1;if(ne?0:e);++rl&&(i=n.apply(f,o)); else{var e=new Ht;!s&&!y&&(c=e);var r=p-(e-c);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:Z}};var Be=ie?function(n,t){ie(n,"__bindData__",{configurable:m,enumerable:m,value:t,writable:m})}:c,$e=de,De=je?function(n){return ht(n)?je(n):[]}:X,Fe={"&":"&","<":"<",">":">",'"':""","'":"'"},Re=gt(Fe),Te=Yt("("+De(Re).join("|")+")","g"),qe=Yt("["+De(Fe).join("")+"]","g"),ze=ot(function(n,t,e){pe.call(n,e)?n[e]++:n[e]=1 +Ie[q]=Vt,Ie[z]=Gt,Ie[W]=Ht,Ie[P]=Jt,Ie[M]=Xt,Ie[K]=Qt,Ie[U]=Yt,Ie[V]=Zt,nt.prototype=Z.prototype;var Ne=Z.support={};Ne.fastBind=be&&!Ae,Z.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:Z}};var Be=ie?function(n,t){var e=l();e.value=t,ie(n,"__bindData__",e),s(e)}:c,$e=de,De=je?function(n){return ht(n)?je(n):[]}:X,Fe={"&":"&","<":"<",">":">",'"':""","'":"'"},Re=gt(Fe),Te=Yt("("+De(Re).join("|")+")","g"),qe=Yt("["+De(Fe).join("")+"]","g"),ze=ot(function(n,t,e){pe.call(n,e)?n[e]++:n[e]=1 }),We=ot(function(n,t,e){(pe.call(n,e)?n[e]:n[e]=[]).push(t)}),Pe=ot(function(n,t,e){n[e]=t});Ae&&Q&&typeof ve=="function"&&(Pt=zt(ve,r));var Ke=8==xe(x+"08")?xe:function(n,t){return xe(mt(n)?n.replace(B,""):n,t||0)};return Z.after=function(n,t){return function(){return 1>--n?t.apply(this,arguments):void 0}},Z.assign=L,Z.at=function(n){for(var t=-1,e=et(arguments,h,m,1),r=e.length,u=Vt(r);++t