network/stack: Clean up hashing logic a bit.
No functional change intended.
This commit is contained in:
@@ -103,21 +103,17 @@ struct ChainHash {
|
|||||||
typedef chain_key KeyType;
|
typedef chain_key KeyType;
|
||||||
typedef chain ValueType;
|
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
|
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
|
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
|
bool Compare(KeyType key, ValueType* chain) const
|
||||||
{
|
{
|
||||||
if (chain->family == key.family
|
if (chain->family == key.family
|
||||||
|
|||||||
Reference in New Issue
Block a user