apfl_value_hash: Return directly instead of "goto ok"
This commit is contained in:
parent
b3322c93e9
commit
82a9858902
1 changed files with 6 additions and 10 deletions
16
src/value.c
16
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue