HaxeFoundation / HaxeFoundation/haxe

Array.removeAt

Open
#4,238 37 comments 0 reactions 0 assignees View on GitHub
standard library
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

Hi,

Deepnight and I think haxe Array misses :

```
function removeAt( pos : Int) : Void;
```

when there is only :

```
function splice( pos : Int, len : Int ) : Array;
```

Splice is very problematique since int creates another array and totally trashes memory. On most platforms this function already exists so here is a big abstraction leak that haxe should fill.

for example on cpp, ths function would not ungrow the memory zone but use a memmove to retrieve the overlappig pointer zone, thus providing a very fast implementation.

So we propose we introduce this function in cross platform.

we can start with a naive implementation which is

```
function removeAt( pos : Int) : Void {
arr.remove( arr[idx] );
}
```

For informations, array is very often the (very) worst offender in memory usage yet the best ergonomic alternative, so we think improving it would be great.

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.