[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
GCArray copies
From: |
Markus Hitter |
Subject: |
GCArray copies |
Date: |
Sat, 27 Nov 2004 04:12:12 +0100 |
Hello
While trying to get GNUstep to compile on Mac OS X 10.1.5 I came across
a detail in GC(Mutable)Array's implementation I can't explain myself.
Both (GCArray's and GCMutableArray's) implementations of
-mutableCopyWithZone: use:
return [[GCMutableArray allocWithZone:zone initWithArray:self
copyItems:NO];
All the objects in the copied array get a retain.
Both immutable copies (-copyWithZone:) are implemented as:
return [[GCArray allocWithZone:zone initWithArray:self
copyItems:YES];
All the objects in the copied array are actually duplicated.
I just fail to see why it makes a difference wether the resulting array
is mutable or not. Doing deep copies has the potential to waste memory,
of course.
Lurking around in all other NSArray and GCArray methods, doing any
creation, expansion or whatever with arrays, the handled objects always
get a retain, only.
With the current implementation,
[(GCArray *)self copyWithZone:0];
and
[[GCArray alloc] initWithArray:self];
gives two different results, surprisingly the later one uses less
memory.
Any insight?
Thanks,
Markus
- - - - - - - - - - - - - - - - - - -
Dipl. Ing. Markus Hitter
http://www.jump-ing.de/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- GCArray copies,
Markus Hitter <=