From 9196cf4b3b30fbd7da07b3e6c72e96b81e7af61c Mon Sep 17 00:00:00 2001 From: Ano-sys Date: Sun, 12 Jan 2025 00:52:18 +0100 Subject: [PATCH] Shortened single line ifs --- webserver.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/webserver.c b/webserver.c index 15f214f..4ef27c2 100644 --- a/webserver.c +++ b/webserver.c @@ -82,15 +82,9 @@ uint16_t hash_uri(const char *uri){ #include static bool in_range(uint16_t me, uint16_t suc, uint16_t hash) { - if (me < suc) { - return (hash > me && hash <= suc); - } - elif (me > suc) { - return (hash > me || hash <= suc); - } - else { - return false; - } + if (me < suc) return (hash > me && hash <= suc); + elif (me > suc) return (hash > me || hash <= suc); + else return false; } neighbor check_neighborhood(uint16_t hash) { @@ -98,15 +92,9 @@ neighbor check_neighborhood(uint16_t hash) { uint16_t id = _NODE_ID; uint16_t suc_id = _SUCC_ID; - if (in_range(id, suc_id, hash)) { - return res_303; - } - else if (in_range(pred_id, id, hash)) { - return res; - } - else { - return not_res; - } + if (in_range(id, suc_id, hash)) return res_303; + elif (in_range(pred_id, id, hash)) return res; + else return not_res; }