Open juj opened 2 months ago
(Lines 2-4 are also something that would be impactful to be able to manually annotate to Closure Compiler to optimize away.. this was discussed in https://github.com/google/closure-compiler/issues/3185 , I see these types of effectively redundant lines in Emscripten output for all users)
Thanks for the report
Input JS:
results in
The last two generated lines look odd. Instead, these two lines would be shorter as
[Online test](https://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540output_file_name%2520default.js%250A%252F%252F%2520%2540compilation_level%2520ADVANCED_OPTIMIZATIONS%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%250Avar%2520buffer%2520%253D%2520new%2520ArrayBuffer(1024)%253B%250Avar%2520HEAPU8%2520%253D%2520new%2520Uint8Array(buffer)%253B%250Avar%2520UTF8Decoder%2520%253D%2520new%2520TextDecoder()%253B%250A%250A%2520%2520var%2520UTF8ToString%2520%253D%2520(ptr%252C%2520maxBytesToRead)%2520%253D%253E%2520%257B%250A%2520%2520%2520%2520%2520%2520if%2520(!ptr)%2520return%2520''%253B%250A%2520%2520%2520%2520%2520%2520var%2520maxPtr%2520%253D%2520ptr%2520%252B%2520maxBytesToRead%253B%250A%2520%2520%2520%2520%2520%2520for%2520(var%2520end%2520%253D%2520ptr%253B%2520!(end%2520%253E%253D%2520maxPtr)%2520%2526%2526%2520HEAPU8%255Bend%255D%253B)%2520%252B%252Bend%253B%250A%2520%2520%2520%2520%2520%2520return%2520UTF8Decoder.decode(HEAPU8.subarray(ptr%252C%2520end))%253B%250A%2520%2520%2520%2520%257D%253B%250A%250A%250Afunction%2520wgpu_canvas_get_webgpu_context(canvasSelector)%2520%257B%250A%2520%2520let%2520canvas%2520%253D%2520document.querySelector(UTF8ToString(canvasSelector))%253B%250A%2520%2520let%2520ctx%2520%253D%2520canvas.getContext('webgpu')%253B%250A%2520%2520return%2520ctx%253B%250A%257D%250A%250Awgpu_canvas_get_webgpu_context(0)%253B%250A)