Get rid of an unnecessary loop.

The loop is not required as we recalculate each entry's
accumulatedWeight on each call, thus there is always an entry that will
be found for the random number.
This commit is contained in:
Jonathan Schleifer 2011-05-26 00:41:26 +02:00
parent a04917a128
commit 9fd6e76322

View file

@ -321,7 +321,6 @@
XMPPSRVEntry *ret; XMPPSRVEntry *ret;
of_list_object_t *iter; of_list_object_t *iter;
uint32_t totalWeight = 0; uint32_t totalWeight = 0;
BOOL loop = YES;
if (done) if (done)
return nil; return nil;
@ -341,10 +340,7 @@
[iter->object setAccumulatedWeight: totalWeight]; [iter->object setAccumulatedWeight: totalWeight];
} }
if ([subListCopy count] == 0) if ([subListCopy count] > 0) {
loop = NO;
while (loop) {
uint32_t randomWeight; uint32_t randomWeight;
RAND_pseudo_bytes((uint8_t*)&randomWeight, sizeof(uint32_t)); RAND_pseudo_bytes((uint8_t*)&randomWeight, sizeof(uint32_t));
@ -357,7 +353,6 @@
[subListCopy removeListObject: iter]; [subListCopy removeListObject: iter];
loop = NO;
break; break;
} }
} }