thank you, do you know how to reuse an array? it seems to reset the capacity when you set the length to 0, so it reallocates when you append to it
```
import std.stdio;
import std.format;

void main()
{
    int[] xs;

    foreach (i ; 0..3)
    {
format("1: length:%s capacity:%s ptr:%s",xs.length, xs.capacity, xs.ptr).writeln;
        xs.length = 0;
format("2: length:%s capacity:%s ptr:%s",xs.length, xs.capacity, xs.ptr).writeln;
        xs ~= i;
format("3: length:%s capacity:%s ptr:%s",xs.length, xs.capacity, xs.ptr).writeln;
        writeln("------------------------");
    }
}
```

gives me
```
1: length:0 capacity:0 ptr:null
2: length:0 capacity:0 ptr:null
3: length:1 capacity:3 ptr:72DECA101020
------------------------
1: length:1 capacity:3 ptr:72DECA101020
2: length:0 capacity:0 ptr:72DECA101020
3: length:1 capacity:3 ptr:72DECA101060
------------------------
1: length:1 capacity:3 ptr:72DECA101060
2: length:0 capacity:0 ptr:72DECA101060
3: length:1 capacity:3 ptr:72DECA1010A0
------------------------
```

Reply via email to