Replace var with const/let in library_(html5_)webgpu.js#21488
Replace var with const/let in library_(html5_)webgpu.js#21488kainino0x wants to merge 1 commit intoemscripten-core:mainfrom
Conversation
sbc100
left a comment
There was a problem hiding this comment.
The funny thing about using these newer constructs is that they can come with downsides:
- At runtime IIUC
varcan be a little faster sinceletandconstinvolve tracking some kind of dead zone information. - They can make the JS larger because
constis a longer string thatvar - They prohibit closure from re-writeing all
vardeclaration into a single one per function (sincelet/constinside blocks are not supposed to be visible outside block).
None of these are a huge deal.. but its why we haven't made efforts to convert over yet.
CC @syg
|
interesting, I had guessed that Closure's analysis would take care of problems like that. A transform must be required for targeting ES5 so I kind of assumed that they would just do it unconditionally, instead of going through the work of preserving let/const when the target is ES6+. Since they do variable renaming, they already know what all the variables resolve to so I'd think they can do it without causing any observable behavior difference. This comment does seem to agree with my suspicion, although it's 3.5 years old. google/closure-compiler#3680 (comment) |
21afb70 to
c6e73a1
Compare
It was my assumption that closure compiler would indeed do this, but last time I tried to do |
|
Sounds like it's time to finally add a WebGPU code size test. I'll try to look into that next week. |
|
Closing for now, filed as a bug in #22496. |
Needs rebase after #21454