mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-20 12:16:40 +00:00
gc improvements
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28234 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4de027cd20
commit
4bb86f10be
8 changed files with 1059 additions and 233 deletions
|
@ -386,6 +386,43 @@ static SEL rlSel;
|
|||
return 0;
|
||||
}
|
||||
|
||||
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*)state
|
||||
objects: (id*)stackbuf
|
||||
count: (NSUInteger)len
|
||||
{
|
||||
NSUInteger size = [self count];
|
||||
NSInteger count;
|
||||
|
||||
/* This is cached in the caller at the start and compared at each
|
||||
* iteration. If it changes during the iteration then
|
||||
* objc_enumerationMutation() will be called, throwing an exception.
|
||||
*/
|
||||
state->mutationsPtr = (unsigned long *)size;
|
||||
count = MIN(len, size - state->state);
|
||||
/* If a mutation has occurred then it's possible that we are being asked to
|
||||
* get objects from after the end of the array. Don't pass negative values
|
||||
* to memcpy.
|
||||
*/
|
||||
if (count > 0)
|
||||
{
|
||||
IMP imp = [self methodForSelector: @selector(objectAtIndex:)];
|
||||
int p = state->state;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++, p++)
|
||||
{
|
||||
stackbuf[i] = (*imp)(self, @selector(objectAtIndex:), p);
|
||||
}
|
||||
state->state += count;
|
||||
}
|
||||
else
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
state->itemsPtr = stackbuf;
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the receiver for storing to archive or sending over an
|
||||
* [NSConnection].
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue