network/stack: Clean up hashing logic a bit.

No functional change intended.
This commit is contained in:
Augustin Cavalier
2024-12-30 15:38:53 -05:00
parent f44cb411cc
commit 4c29a795ad
+3 -7
View File
@@ -103,21 +103,17 @@ struct ChainHash {
typedef chain_key KeyType;
typedef chain ValueType;
// TODO: check if this makes a good hash...
#define HASH(o) ((uint32)(((o)->family) ^ ((o)->type) ^ ((o)->protocol)))
size_t HashKey(KeyType key) const
{
return HASH(&key);
// TODO: check if this makes a good hash...
return (uint32)(key.family ^ key.type ^ key.protocol);
}
size_t Hash(ValueType* value) const
{
return HASH(value);
return HashKey(chain_key { value->family, value->type, value->protocol });
}
#undef HASH
bool Compare(KeyType key, ValueType* chain) const
{
if (chain->family == key.family