HaxeFoundation / HaxeFoundation/haxe
Fixed size Array map
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
When doing the following (in a map function for instance):
```haxe
case TBlock(el): return [for( e in el ) f(e)];
```
This will translate to:
```haxe
var tmp = [];
for( e in el ) tmp.push(f(e));
return tmp;
```
It would be nice if we had something such as `Array.make(length)` that would preallocate an array for the given size. Would really optimize memory since the output "tmp" array would not be expanded (potential several times) during the for, and would only use the exact amount of memory necessary.
That would turn the array mapping into:
```haxe
var tmp = Array.make(el.length);
for( e in el ) tmp.push(f(e));
return tmp;
```
Contributor guide
Assessment
This issue has not been assessed yet.