From 68f96c3d282cbb277477f960396d8e09345feec5 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Thu, 24 Oct 2013 13:51:45 -0400 Subject: [PATCH 1/2] Use a less-clever for-loop to reset temporary context variables. This style also saves six gzip'd bytes. --- runtime/dev.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/runtime/dev.js b/runtime/dev.js index 1b381ac721f9..99a8a6fb5ccf 100644 --- a/runtime/dev.js +++ b/runtime/dev.js @@ -125,12 +125,10 @@ // Pre-initialize at least 20 temporary variables to enable hidden // class optimizations for simple generators. - var tempIndex = 0; - var tempName; - while ((tempName = "t" + tempIndex) && - (tempIndex < 20 || hasOwn.call(this, tempName))) { + for (var tempIndex = 0, tempName; + hasOwn.call(this, tempName = "t" + tempIndex) || tempIndex < 20; + ++tempIndex) { this[tempName] = null; - ++tempIndex; } }, From fc25eea6597140bbdba3fb9742161d6138b8e341 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Thu, 24 Oct 2013 13:52:08 -0400 Subject: [PATCH 2/2] Regenerate runtime/min.js from runtime/dev.js. Command used: uglifyjs dev.js --mangle --compress --comments /Copyright/ --output min.js --- runtime/min.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runtime/min.js b/runtime/min.js index 1c45eed305a8..e70a5f3db59f 100644 --- a/runtime/min.js +++ b/runtime/min.js @@ -6,5 +6,4 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ - -!function(t){function e(t,e){return new n(t,e||null)}function n(t,e){function n(){f=h;do var n=t.call(e,u);while(n===s);return f=u.done?c:a,{value:n,done:u.done}}function i(){if(f===h)throw new Error("Generator is already running");if(f===c)throw new Error("Generator has already finished")}var l=this,u=new r,f=o;l.next=function(t){if(i(),u.delegate){var e=u.delegate.next(t);if(!e.done)return e;u.delegate=null}for(f===a&&(u.sent=t);;)try{return n()}catch(r){u.dispatchException(r)}},l["throw"]=function(t){if(i(),u.delegate){var e=u.delegate["throw"](t);if(!e.done)return e;u.delegate=null}if(f===o)throw f=c,t;for(;;)try{return u.dispatchException(t),n()}catch(r){t=r}}}function r(){this.reset()}var i=Object.prototype.hasOwnProperty;if(!t.wrapGenerator){t.wrapGenerator=e,"undefined"!=typeof exports&&(exports.wrapGenerator=e);var o="suspendedStart",a="suspendedYield",h="executing",c="completed",s={};r.prototype={constructor:r,reset:function(){this.next=0,this.sent=void 0,this.tryStack=[],this.done=!1,this.delegate=null;for(var t,e=0;t="t"+e,20>e||i.call(this,t);)this[t]=null,++e},stop:function(){if(i.call(this,"thrown")){var t=this.thrown;throw delete this.thrown,t}return this.done=!0,this.rval},keys:function(t){return Object.keys(t).reverse()},pushTry:function(t,e,n){e&&this.tryStack.push({finallyLoc:e,finallyTempVar:n}),t&&this.tryStack.push({catchLoc:t})},popCatch:function(t){var e=this.tryStack.length-1,n=this.tryStack[e];n&&n.catchLoc===t&&(this.tryStack.length=e)},popFinally:function(t){var e=this.tryStack.length-1,n=this.tryStack[e];n&&i.call(n,"finallyLoc")||(n=this.tryStack[--e]),n&&n.finallyLoc===t&&(this.tryStack.length=e)},dispatchException:function(t){var e,n=[],r=!1;if(this.done)throw t;for(var i=this.tryStack.length-1;i>=0;--i){if(e=this.tryStack[i],e.catchLoc){this.thrown=t,this.next=e.catchLoc,r=!0;break}e.finallyLoc&&(n.push(e),r=!0)}if(!r)throw t;for(;e=n.pop();)this[e.finallyTempVar]=this.next,this.next=e.finallyLoc},delegateYield:function(t,e){this.next=e;var n=t.next(this.sent);return n.done?(this.delegate=null,s):(this.delegate=t,n.value)}}}}(Function("return this")()); \ No newline at end of file +!function(t){function e(t,e){return new n(t,e||null)}function n(t,e){function n(){f=h;do var n=t.call(e,u);while(n===s);return f=u.done?c:a,{value:n,done:u.done}}function i(){if(f===h)throw new Error("Generator is already running");if(f===c)throw new Error("Generator has already finished")}var l=this,u=new r,f=o;l.next=function(t){if(i(),u.delegate){var e=u.delegate.next(t);if(!e.done)return e;u.delegate=null}for(f===a&&(u.sent=t);;)try{return n()}catch(r){u.dispatchException(r)}},l["throw"]=function(t){if(i(),u.delegate){var e=u.delegate["throw"](t);if(!e.done)return e;u.delegate=null}if(f===o)throw f=c,t;for(;;)try{return u.dispatchException(t),n()}catch(r){t=r}}}function r(){this.reset()}var i=Object.prototype.hasOwnProperty;if(!t.wrapGenerator){t.wrapGenerator=e,"undefined"!=typeof exports&&(exports.wrapGenerator=e);var o="suspendedStart",a="suspendedYield",h="executing",c="completed",s={};r.prototype={constructor:r,reset:function(){this.next=0,this.sent=void 0,this.tryStack=[],this.done=!1,this.delegate=null;for(var t,e=0;i.call(this,t="t"+e)||20>e;++e)this[t]=null},stop:function(){if(i.call(this,"thrown")){var t=this.thrown;throw delete this.thrown,t}return this.done=!0,this.rval},keys:function(t){return Object.keys(t).reverse()},pushTry:function(t,e,n){e&&this.tryStack.push({finallyLoc:e,finallyTempVar:n}),t&&this.tryStack.push({catchLoc:t})},popCatch:function(t){var e=this.tryStack.length-1,n=this.tryStack[e];n&&n.catchLoc===t&&(this.tryStack.length=e)},popFinally:function(t){var e=this.tryStack.length-1,n=this.tryStack[e];n&&i.call(n,"finallyLoc")||(n=this.tryStack[--e]),n&&n.finallyLoc===t&&(this.tryStack.length=e)},dispatchException:function(t){var e,n=[],r=!1;if(this.done)throw t;for(var i=this.tryStack.length-1;i>=0;--i){if(e=this.tryStack[i],e.catchLoc){this.thrown=t,this.next=e.catchLoc,r=!0;break}e.finallyLoc&&(n.push(e),r=!0)}if(!r)throw t;for(;e=n.pop();)this[e.finallyTempVar]=this.next,this.next=e.finallyLoc},delegateYield:function(t,e){this.next=e;var n=t.next(this.sent);return n.done?(this.delegate=null,s):(this.delegate=t,n.value)}}}}(Function("return this")()); \ No newline at end of file