HaxeFoundation / HaxeFoundation/haxe
amount of code for js object iteration
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
Hi,
in haxe 4.1.3 (most likely other as well), unnecessary amount of code is generated for simple object iteration, for example:
```haxe
class Main {
static function main()
{
var set = new js.lib.Set();
for(key in set)
trace(key);
}
}
```
compiled by `haxe --main Main --js main.js -D js-es=6` results in:
```js
let set = new Set();
let jsIterator = set.values();
let _g_jsIterator = jsIterator;
let _g_lastStep = jsIterator.next();
while(!_g_lastStep.done) {
let v = _g_lastStep.value;
_g_lastStep = _g_jsIterator.next();
let key = v;
console.log("Main.hx:6:",key);
}
```
while runtime/browser would be happy with single line of code:
```js
let set = new Set();
for(let key of set)
console.log("Main.hx:6:",key);
```
Would it possible to optimize compiler to reduce the output. Or is there any existing compiler flag available?
thanks
Contributor guide
Assessment
This issue has not been assessed yet.