redjack/libcork — pull request #65 by dcreager (2013-09-12 15:55:49+00:00)
Title: Hash table initialization

All of the cork hash tables seem to be initialized to zero bins. The default,
```
#define CORK_HASH_TABLE_DEFAULT_INITIAL_SIZE 8
```
does not appear to be used anywhere in `hash-table.c` and the `cork_hash_table_init` function which is called directly or indirectly by all of the `init` and `new` hash table functions completely ignores its `initial_size` parameter. The only place where a size is actually set is in the `cork_hash_table_ensure_size` function.

The net result is that the first attempt at a hash entry will cause a single bin to be allocated (I think) and the effective hash mask will be 0. A second bin will be allocated when the entry count reaches 5, etc. While this may not matter much if the hash tables grow quickly, it will be expensive if we have many small hash tables and it makes it impossible for the coder who knows the approximate number of hash entries to expect to avoid the reallocations.