mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +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
|
objects: (id*)stackbuf
|
||||||
count: (NSUInteger)len
|
count: (NSUInteger)len
|
||||||
{
|
{
|
||||||
NSInteger count;
|
NSInteger count;
|
||||||
|
NSHashEnumerator enumerator;
|
||||||
|
|
||||||
state->mutationsPtr = (unsigned long *)version;
|
state->mutationsPtr = (unsigned long *)version;
|
||||||
if (state->state == 0 && state->extra[0] == 0)
|
if (state->state == 0 && state->extra[0] == 0)
|
||||||
{
|
{
|
||||||
while (state->extra[0] < bucketCount)
|
enumerator = GSIMapEnumeratorForMap(self);
|
||||||
{
|
}
|
||||||
state->state = (unsigned long)buckets[state->extra[0]].firstNode;
|
else
|
||||||
if (state->state != 0)
|
{
|
||||||
{
|
enumerator.map = self;
|
||||||
break; // Got first node, and recorded its bucket.
|
enumerator.node = (GSIMapNode)(uintptr_t)state->state;
|
||||||
}
|
enumerator.bucket = state->extra[0];
|
||||||
state->extra[0]++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (count = 0; count < len; count++)
|
for (count = 0; count < len; count++)
|
||||||
{
|
{
|
||||||
GSIMapNode node = (GSIMapNode)state->state;
|
GSIMapNode node = GSIMapEnumeratorNextNode(&enumerator);
|
||||||
|
|
||||||
if (node == 0)
|
if (node == 0)
|
||||||
{
|
{
|
||||||
|
@ -885,22 +884,11 @@ const NSHashTableCallBacks NSPointerToStructHashCallBacks =
|
||||||
}
|
}
|
||||||
else
|
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;
|
stackbuf[count] = node->key.obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
state->state = (unsigned long)(uintptr_t)enumerator.node;
|
||||||
|
state->extra[0] = enumerator.bucket;
|
||||||
state->itemsPtr = stackbuf;
|
state->itemsPtr = stackbuf;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1147,24 +1147,23 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
|
||||||
objects: (id*)stackbuf
|
objects: (id*)stackbuf
|
||||||
count: (NSUInteger)len
|
count: (NSUInteger)len
|
||||||
{
|
{
|
||||||
NSInteger count;
|
NSInteger count;
|
||||||
|
NSMapEnumerator enumerator;
|
||||||
|
|
||||||
state->mutationsPtr = (unsigned long *)version;
|
state->mutationsPtr = (unsigned long *)version;
|
||||||
if (state->state == 0 && state->extra[0] == 0)
|
if (state->state == 0 && state->extra[0] == 0)
|
||||||
{
|
{
|
||||||
while (state->extra[0] < bucketCount)
|
enumerator = GSIMapEnumeratorForMap(self);
|
||||||
{
|
}
|
||||||
state->state = (unsigned long)buckets[state->extra[0]].firstNode;
|
else
|
||||||
if (state->state != 0)
|
{
|
||||||
{
|
enumerator.map = self;
|
||||||
break; // Got first node, and recorded its bucket.
|
enumerator.node = (GSIMapNode)(uintptr_t)state->state;
|
||||||
}
|
enumerator.bucket = state->extra[0];
|
||||||
state->extra[0]++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (count = 0; count < len; count++)
|
for (count = 0; count < len; count++)
|
||||||
{
|
{
|
||||||
GSIMapNode node = (GSIMapNode)state->state;
|
GSIMapNode node = GSIMapEnumeratorNextNode(&enumerator);
|
||||||
|
|
||||||
if (node == 0)
|
if (node == 0)
|
||||||
{
|
{
|
||||||
|
@ -1172,22 +1171,11 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
|
||||||
}
|
}
|
||||||
else
|
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;
|
stackbuf[count] = node->key.obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
state->state = (unsigned long)(uintptr_t)enumerator.node;
|
||||||
|
state->extra[0] = enumerator.bucket;
|
||||||
state->itemsPtr = stackbuf;
|
state->itemsPtr = stackbuf;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue