Major performance problem with std.array.front()

Steven Schveighoffer schveiguy at yahoo.com
Mon Mar 10 19:07:18 PDT 2014


On Mon, 10 Mar 2014 19:59:07 -0400, Walter Bright  
<newshound2 at digitalmars.com> wrote:

> On 3/10/2014 6:47 AM, Dicebot wrote:
>> (array literals that allocate, I will never forgive that).
>
> It was done that way simply to get it up and running quickly. Having  
> them not allocate is an optimization, it doesn't change the nature.

I think you forget about this:

foo(int v, int w)
{
    auto x = [v, w];
}

Which cannot pre-allocate.

That said, I would not mind if this code broke and you had to use array(v,  
w) instead, for the sake of avoiding unnecessary allocations.

-Steve


More information about the Digitalmars-d mailing list