google / google/closure-compiler
Some var declarations not being collapsed into a single var declaration
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
@MatrixFrog After your commit https://github.com/google/closure-compiler/commit/89c8747df70a7a25af1623d71057db50ba841248 I get some `var` declarations not being collapsed into a single `var a,b,c;` declaration which leads in increasing the compiled code size. Is it intended?
```javascript
Zipper.prototype._setDosDateTime = function() {
/** @type {!Zipper} */
var me = this;
/** @type {!Date} */
var date = new Date();
/** @type {number} */
var ret = 0;
ret |= (date.getFullYear() - 1980) << 25;
ret |= (date.getMonth() + 1) << 21;
ret |= date.getDate() << 16;
ret |= date.getHours() << 11;
ret |= date.getMinutes() << 5;
ret |= date.getSeconds() >> 1;
me._dosDateTime = ret;
};
```
Before your commit this method was compiled into:
```javascript
function xc(a){var b=new Date,c;c=0|b.getFullYear()-1980<<25;c|=b.getMonth()+1<<21;c|=b.getDate()<<16;c|=b.getHours()<<11;c|=b.getMinutes()<<5;c|=b.getSeconds()>>1;a.Ec=c}
```
And now I get (notice the double `var` declaration):
```javascript
function xc(a){var b=new Date;var c=0|b.getFullYear()-1980<<25;c|=b.getMonth()+1<<21;c|=b.getDate()<<16;c|=b.getHours()<<11;c|=b.getMinutes()<<5;c|=b.getSeconds()>>1;a.Ec=c}
```
Contributor guide
Assessment
This issue has not been assessed yet.