Thread overview
[Issue 15481] GC profiler thinks reducing array.length triggers reallocation
Dec 28, 2015
ag0aep6g@gmail.com
Dec 28, 2015
Valentin Milea
December 28, 2015
https://issues.dlang.org/show_bug.cgi?id=15481

ag0aep6g@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ag0aep6g@gmail.com
            Summary|Reducing array.length       |GC profiler thinks reducing
                   |triggers reallocation       |array.length triggers
                   |                            |reallocation

--- Comment #1 from ag0aep6g@gmail.com ---
This is a bug in the GC profiler. The array is not relocated. You can check by comparing the pointers:

----
void main()
{
    int[] arr;
    arr.length = 7;
    int* p = arr.ptr;
    arr.length = 6;
    assert(arr.ptr == p); /* passes */
}
----

I'm changing the title of this issue accordingly.

--
December 28, 2015
https://issues.dlang.org/show_bug.cgi?id=15481

--- Comment #2 from Valentin Milea <valentin.milea@gmail.com> ---
Maybe the reallocation function is called and returns the same buffer. But why call it in the first place, if reducing array length is supposed to be _equivalent_ to slicing?

--
April 20
https://issues.dlang.org/show_bug.cgi?id=15481

Leandro Lucarella <leandro.lucarella@sociomantic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |leandro.lucarella@sociomant
                   |                            |ic.com
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=17294

--
April 20
https://issues.dlang.org/show_bug.cgi?id=15481

Leandro Lucarella <leandro.lucarella@sociomantic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=16280

--