Immutable data not copied

Simen kjaeraas simen.kjaras at gmail.com
Tue Dec 8 16:54:54 PST 2009


On Wed, 09 Dec 2009 01:18:46 +0100, Tomek Sowiński <just at ask.me> wrote:

> const(FAQ) says: "When doing a deep copy of a data structure, the  
> invariant portions need not be copied."
> I'm trying to imagine what code would benefit from such optimization.
>
> immutable struct Large { whole lotta data... }
>
> struct Other { Large l; }
>
> void funkcja(Large s);  // no reference annotation on parameter, copied?
> {
>     Large t = s;   // copied?
>     auto other = Other(s);  // copied?
>     Other o = other;  // other.l copied?
> }
>
>
> Tomek

Deep copy means follow references and pointers, so it refers to references  
and pointers, not POD.

-- 
Simen


More information about the Digitalmars-d-learn mailing list