mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
tidied enumeration code
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28235 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4bb86f10be
commit
04fc6f6d68
2 changed files with 24 additions and 48 deletions
|
@ -860,24 +860,23 @@ const NSHashTableCallBacks NSPointerToStructHashCallBacks =
|
|||
objects: (id*)stackbuf
|
||||
count: (NSUInteger)len
|
||||
{
|
||||
NSInteger count;
|
||||
NSInteger count;
|
||||
NSHashEnumerator enumerator;
|
||||
|
||||
state->mutationsPtr = (unsigned long *)version;
|
||||
if (state->state == 0 && state->extra[0] == 0)
|
||||
{
|
||||
while (state->extra[0] < bucketCount)
|
||||
{
|
||||
state->state = (unsigned long)buckets[state->extra[0]].firstNode;
|
||||
if (state->state != 0)
|
||||
{
|
||||
break; // Got first node, and recorded its bucket.
|
||||
}
|
||||
state->extra[0]++;
|
||||
}
|
||||
enumerator = GSIMapEnumeratorForMap(self);
|
||||
}
|
||||
else
|
||||
{
|
||||
enumerator.map = self;
|
||||
enumerator.node = (GSIMapNode)(uintptr_t)state->state;
|
||||
enumerator.bucket = state->extra[0];
|
||||
}
|
||||
for (count = 0; count < len; count++)
|
||||
{
|
||||
GSIMapNode node = (GSIMapNode)state->state;
|
||||
GSIMapNode node = GSIMapEnumeratorNextNode(&enumerator);
|
||||
|
||||
if (node == 0)
|
||||
{
|
||||
|
@ -885,22 +884,11 @@ const NSHashTableCallBacks NSPointerToStructHashCallBacks =
|
|||
}
|
||||
else
|
||||
{
|
||||
GSIMapNode next = node->nextInBucket;
|
||||
|
||||
if (next == 0)
|
||||
{
|
||||
size_t bucket = state->extra[0];
|
||||
|
||||
while (next == 0 && ++bucket < bucketCount)
|
||||
{
|
||||
next = buckets[bucket].firstNode;
|
||||
}
|
||||
state->extra[0] = bucket;
|
||||
}
|
||||
state->state = (unsigned long)(uintptr_t)next;
|
||||
stackbuf[count] = node->key.obj;
|
||||
}
|
||||
}
|
||||
state->state = (unsigned long)(uintptr_t)enumerator.node;
|
||||
state->extra[0] = enumerator.bucket;
|
||||
state->itemsPtr = stackbuf;
|
||||
return count;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue