Hashing

In order to ensure the Store performs well, we must ensure that certain processes run efficiently - notably searching for an existing entry, insertion and deletion.

Accordingly, the Store is implemented based on a hash table. For every `key', we need to be able to form a hash, but this process is complicated slightly by the fact that every different fz_storable has a different type for the key.

We solve this by having the make_hash_key member of the fz_store_type structure convert whatever its key data is into a common structure:


\begin{lstlisting}
typedef struct fz_store_hash_s
{
fz_store_drop_fn *drop;
un...
...ink; /* 36 bytes */
} u;
} fz_store_hash; /* 40 or 44 bytes */
\end{lstlisting}

The caller will always arrange for this structure to be zero filled on entry to the make_hash_key call. On exit, it should have been updated with the key details. Implementers may extend the union found in this structure as required, though ideally the size of the overall structure should be minimised to avoid unnecessary work.

Once the Store has formed a fz_store_hash it can then generate the required hash for the hash table as required.