From 82a9858902aef503ddeaeb84d8ef951415acd5b9 Mon Sep 17 00:00:00 2001 From: Laria Carolin Chabowski Date: Fri, 15 Apr 2022 14:49:28 +0200 Subject: [PATCH] apfl_value_hash: Return directly instead of "goto ok" --- src/value.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/value.c b/src/value.c index 58ee004..8f23873 100644 --- a/src/value.c +++ b/src/value.c @@ -450,33 +450,29 @@ apfl_value_hash(const struct apfl_value value) switch (value.type) { case VALUE_NIL: - goto ok; + return hash; case VALUE_BOOLEAN: - hash = apfl_hash_fnv1a_add(&value.boolean, sizeof(bool), hash); - goto ok; + return apfl_hash_fnv1a_add(&value.boolean, sizeof(bool), hash); case VALUE_NUMBER: - hash = apfl_hash_fnv1a_add(&value.number, sizeof(apfl_number), hash); - goto ok; + return apfl_hash_fnv1a_add(&value.number, sizeof(apfl_number), hash); case VALUE_STRING: sv = apfl_string_view_from(*value.string); - hash = apfl_hash_fnv1a_add(sv.bytes, sv.len, hash); - goto ok; + return apfl_hash_fnv1a_add(sv.bytes, sv.len, hash); case VALUE_LIST: for (size_t i = 0; i < value.list->len; i++) { apfl_hash item_hash = apfl_value_hash(value.list->items[i]); hash = apfl_hash_fnv1a_add(&item_hash, sizeof(apfl_hash), hash); } - goto ok; + return hash; case VALUE_DICT: // TODO: This results in all dictionaries having the same hash. Since // it's rather unusual to have dictionaries as keys, this is fine // for now, but should be improved nonetheless! - goto ok; + return hash; } assert(false); -ok: return hash; }