From 19bd38999bd22e2d47cfd84a1616a4eedf1fc90d Mon Sep 17 00:00:00 2001 From: tux3 Date: Tue, 19 May 2015 19:53:55 +0200 Subject: Remove pointless nullity check on array address assoc->self_client_id is always true, therefore we can remove it from that if" -m "The if thus asserts !assoc->self_hash, so we can elide the immediately following if (!assoc->self_hash) --- toxcore/assoc.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/toxcore/assoc.c b/toxcore/assoc.c index 3dbeba51..2e03dabe 100644 --- a/toxcore/assoc.c +++ b/toxcore/assoc.c @@ -510,20 +510,18 @@ static uint8_t candidates_create_new(const Assoc *assoc, hash_t hash, const uint static void client_id_self_update(Assoc *assoc) { - if (assoc->self_hash || !assoc->self_client_id) + if (assoc->self_hash) return; - if (!assoc->self_hash) { - size_t i, sum = 0; + size_t i, sum = 0; - for (i = 0; i < crypto_box_PUBLICKEYBYTES; i++) - sum |= assoc->self_client_id[i]; + for (i = 0; i < crypto_box_PUBLICKEYBYTES; i++) + sum |= assoc->self_client_id[i]; - if (!sum) - return; + if (!sum) + return; - assoc->self_hash = id_hash(assoc, assoc->self_client_id); - } + assoc->self_hash = id_hash(assoc, assoc->self_client_id); LOGGER_DEBUG("id is now set, purging cache of self-references"); @@ -532,7 +530,7 @@ static void client_id_self_update(Assoc *assoc) */ bucket_t b_id = candidates_id_bucket(assoc, assoc->self_client_id); candidates_bucket *cnd_bckt = &assoc->candidates[b_id]; - size_t i, pos = assoc->self_hash % assoc->candidates_bucket_size; + size_t pos = assoc->self_hash % assoc->candidates_bucket_size; for (i = 0; i < HASH_COLLIDE_COUNT; pos = hash_collide(assoc, pos), i++) { Client_entry *entry = &cnd_bckt->list[pos]; -- cgit v1.2.3