HaxeFoundation / HaxeFoundation/haxe

Map.get double cast is ugly

Open
#6,306 0 comments 0 reactions 1 assignee Claimed by @Simn View on GitHub
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

The following simple code:

```haxe
class Main {

var m : Map;

function new() {
m = new Map();
}

function get( bits : Int ) {
return m.get(bits);
}

static function main() {
var m = new Main();
m.get(55);
}

}
```

generates the following ugly thing:

```
function get[Function:bits : Int -> Null]
[Arg:Int] [Local bits(4290):Int]
[Block:Dynamic]
[Return:Dynamic]
[Call:Null]
[Field:key : Int -> Null]
[Cast:haxe.ds.IntMap]
[Cast:IMap]
[Field:Map]
[Const:Main] this
[FInstance:Map]
Main
m
[FInstance:key : Int -> Null]
haxe.ds.IntMap
get
[Local bits(4290):Int]
```

Could we get rid of the double cast here? it's causing some extra runtime checks in HL (and I guess other platforms as well) for every access.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.