Shortened single line ifs
This commit is contained in:
+6
-18
@@ -82,15 +82,9 @@ uint16_t hash_uri(const char *uri){
|
||||
#include <stdint.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user