Request for pre-review: std.serialization/orange

Jacob Carlborg doob at me.com
Tue Oct 4 23:39:48 PDT 2011


On 2011-10-05 03:49, Robert Jacques wrote:
> On Tue, 04 Oct 2011 12:54:27 -0400, Jacob Carlborg <doob at me.com> wrote:
>
>> On 2011-10-04 17:14, Robert Jacques wrote:
>>> I'm sorry, you're right. In my mind b extended to the end of the a
>>> array, for some reason. However, if you do define b to extend to the end
>>> of the a array, then it can append without allocating:
>>>
>>> auto a = [0, 1, 2, 3, 4];
>>> auto b = a[2 .. $];
>>> b ~= 5;
>>> assert(b[0]==2);
>>> a[2] = 10;
>>> assert(b[0]==10);
>>>
>>> So please don't dismiss this point.
>>>
>>
>> Hmm, D1 and D2 behaves differently in this case. In D1 "a" is not
>> changed when "b" is changed. Since you append to "b" I though that it
>> would always require a reallocation of "b".
>
> Appending has never mandated reallocation. Maybe you're confusing it
> with concatenation (i.e. b = b ~ 5;), which does always reallocate. Or
> the period in time when the anti-array-stomping parts of druntime was
> overly conservative and would have prevented b from appending in place.

Yeah, maybe you're right.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list