-
Notifications
You must be signed in to change notification settings - Fork 360
Closed
Description
Not sure which particular project this issue belongs to, but I guess let's track it here for now.
Currently microbundle results in extra bytes in code using for-of (found this as part of dlv experiments).
Example:
export default function dlv(arr, x, sum) {
sum = 0;
for (x of arr) {
sum += x;
}
return sum;
}Currently results in:
export default function(r,t,e){e=0;for(var n=0,f=r;n<f.length;n+=1)e+=f[n];return e}This is suboptimal for several reasons:
- When
for-ofis done over an existing variable, the result currently introduces yet another one -f- just to store the array again. tis completely unused in the result, when it could be reused for other purposes (e.g. the counter).n+=1should be replaced with justf++.
An optimal output would instead look like:
export default function(r,t,e){for(t=0,e=0;t<r.length;t++)e+=r[t];return e}developit
Metadata
Metadata
Assignees
Labels
No labels