Index: src/XMPPSRVEnumerator.m ================================================================== --- src/XMPPSRVEnumerator.m +++ src/XMPPSRVEnumerator.m @@ -319,11 +319,10 @@ - (id)nextObject { XMPPSRVEntry *ret; of_list_object_t *iter; uint32_t totalWeight = 0; - BOOL loop = YES; if (done) return nil; if (listIter == NULL) @@ -339,14 +338,11 @@ iter = iter->next) { totalWeight += [iter->object weight]; [iter->object setAccumulatedWeight: totalWeight]; } - if ([subListCopy count] == 0) - loop = NO; - - while (loop) { + if ([subListCopy count] > 0) { uint32_t randomWeight; RAND_pseudo_bytes((uint8_t*)&randomWeight, sizeof(uint32_t)); randomWeight %= (totalWeight + 1); @@ -355,11 +351,10 @@ if ([iter->object accumulatedWeight] >= randomWeight) { ret = [[iter->object retain] autorelease]; [subListCopy removeListObject: iter]; - loop = NO; break; } } }