Re: Strange behavior on shrinking a Dynamic Array -- Capacity reduces to 0

2011-06-23 Thread dsimcha
== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article > On Thu, 23 Jun 2011 00:15:12 -0400, d coder wrote: > >> > >> > >> Yes. Capacity is only non-zero for arrays which can safely be extended. > >> If > >> you shrink an array from length 10 to length 5, the GC is smart enough > >> to

Re: Strange behavior on shrinking a Dynamic Array -- Capacity reduces to 0

2011-06-23 Thread Steven Schveighoffer
On Thu, 23 Jun 2011 00:15:12 -0400, d coder wrote: Yes. Capacity is only non-zero for arrays which can safely be extended. If you shrink an array from length 10 to length 5, the GC is smart enough to know that that there may be a dangling reference to elements [5..10] and thus if the len

Re: Strange behavior on shrinking a Dynamic Array -- Capacity reduces to 0

2011-06-22 Thread d coder
> > > Yes. Capacity is only non-zero for arrays which can safely be extended. If > you shrink an array from length 10 to length 5, the GC is smart enough to > know that that there may be a dangling reference to elements [5..10] and > thus if the length 5 array was appended to, it might stomp on som

Re: Strange behavior on shrinking a Dynamic Array -- Capacity reduces to 0

2011-06-22 Thread Steven Schveighoffer
On Wed, 22 Jun 2011 23:38:30 -0400, d coder wrote: Hello List As per TDPL and D documentation, shrinking a dynamic array should not relocate it. But that is exactly what is happening. On shrinking an array, its capacity is getting reduced to 0. Surprisingly the capacity after a shrink is even

Re: Strange behavior on shrinking a Dynamic Array -- Capacity reduces to 0

2011-06-22 Thread Ali Çehreli
On Wed, 22 Jun 2011 23:55:23 -0400, Robert Jacques wrote: > On Wed, 22 Jun 2011 23:38:30 -0400, d coder > wrote: > >> Hello List >> >> As per TDPL and D documentation, shrinking a dynamic array should not >> relocate it. But that is exactly what is happening. On shrinking an >> array, its capaci

Re: Strange behavior on shrinking a Dynamic Array -- Capacity reduces to 0

2011-06-22 Thread Robert Jacques
On Wed, 22 Jun 2011 23:38:30 -0400, d coder wrote: Hello List As per TDPL and D documentation, shrinking a dynamic array should not relocate it. But that is exactly what is happening. On shrinking an array, its capacity is getting reduced to 0. Surprisingly the capacity after a shrink is even

Strange behavior on shrinking a Dynamic Array -- Capacity reduces to 0

2011-06-22 Thread d coder
Hello List As per TDPL and D documentation, shrinking a dynamic array should not relocate it. But that is exactly what is happening. On shrinking an array, its capacity is getting reduced to 0. Surprisingly the capacity after a shrink is even less than the length of the array. As a result the arra