From 9fd6e76322c33a857c38b1dbfb07ece25b4dc914 Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Thu, 26 May 2011 00:41:26 +0200 Subject: [PATCH] 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. --- src/XMPPSRVEnumerator.m | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/XMPPSRVEnumerator.m b/src/XMPPSRVEnumerator.m index 385ea1a..2ffb7ea 100644 --- a/src/XMPPSRVEnumerator.m +++ b/src/XMPPSRVEnumerator.m @@ -321,7 +321,6 @@ XMPPSRVEntry *ret; of_list_object_t *iter; uint32_t totalWeight = 0; - BOOL loop = YES; if (done) return nil; @@ -341,10 +340,7 @@ [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)); @@ -357,7 +353,6 @@ [subListCopy removeListObject: iter]; - loop = NO; break; } }