P4C
The P4 Compiler
 
Loading...
Searching...
No Matches
Util::Hasher< T * > Struct Template Reference

Public Member Functions

size_t operator() (T *val) const
 

Detailed Description

template<typename T>
struct Util::Hasher< T * >

In general, pointers are bad hashes: their low 2-3 bits are zero, likewise for the upper bits depending on the ABI. Also, the middle bits might not have enough entropy as addresses come from some common pool. To solve this problem we just use a single iteration of hash_avalanche to improve mixing (see Detail::IntegerHasher).