HaxeFoundation / HaxeFoundation/haxe

Fixed size Array map

Open
#9,004 5 comments 0 reactions 0 assignees View on GitHub
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

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.