Flip default parameter template (#4515)
* Flip default parameter template YMMV, I saved ~10b on a 2kb library. Not noticeable at the small scale, by why not do it anyway? I've (unscientifically) found that flipping the default parameter conditional yields better gzip results. I think this is due to the slightly longer string it can now repeatedly match: ```js // old var param = arguments.length <= 0 || void 0 === arguments[0] ? null : arguments[0] --------------------------------------------------------------^ // new var param = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : null ------------------------------------------------------------------------^ ``` Though it's entirely likely gzip will also choose up to the index of the arguments if you many default parameters at different indexes. * Update tests
This commit is contained in:
committed by
Logan Smyth
parent
08b45ca853
commit
c2ed9de7fb
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
var foo = exports.foo = function foo(gen) {
|
||||
var ctx = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
|
||||
var ctx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
||||
};
|
||||
|
||||
var bar = exports.bar = function bar(gen) {
|
||||
var ctx = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
|
||||
};
|
||||
var ctx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
||||
};
|
||||
Reference in New Issue
Block a user