RFC: naming for FrontTransversal and Transversal ranges

Rainer Deyke rainerd at eldwood.com
Fri May 1 11:03:44 PDT 2009


Robert Jacques wrote:
> On Thu, 30 Apr 2009 23:18:13 -0400, Rainer Deyke <rainerd at eldwood.com>
> wrote:
>>   - It uses an extra heap allocation per instance.
> 
> And during a deep copy, you're often making a lot of heap copies. (N vs
> N+1 when N>>1)

In the case of dynamic arrays, N = 1 (or possibly 0 if the small array
optimization is used).  In the case of static arrays, N = 0.  Either
way, the extra level of indirection is significant.

>>   - It allocates an extra reference to a virtual function table per
>> instance.
> 
> Huh? Isn't that part of the extra heap allocation?

Extra allocations: 1.

Extra memory usage: 2 words (virtual function table pointer, local
pointer) plus heap overhead for one allocation.

> Also, a really important question is: is it possible to implement are
> shared, lock-free containers as value types?


Is it possible to implement them as reference types?  Why would the
issues different between reference types and value types?  A reference
type is just a reference wrapper around a value type.


-- 
Rainer Deyke - rainerd at eldwood.com



More information about the Digitalmars-d mailing list