Many popular symbols are quite short, e.g. "[B", "()V" etc. FNV-1a is reasonably fast and sufficiently random.
| 68 | // Many popular symbols are quite short, e.g. "[B", "()V" etc. |
| 69 | // FNV-1a is reasonably fast and sufficiently random. |
| 70 | unsigned int Dictionary::hash(const char* key, size_t length) { |
| 71 | unsigned int h = 2166136261U; |
| 72 | for (size_t i = 0; i < length; i++) { |
| 73 | h = (h ^ key[i]) * 16777619; |
| 74 | } |
| 75 | return h; |
| 76 | } |
| 77 | |
| 78 | unsigned int Dictionary::lookup(const char* key) { |
| 79 | return lookup(key, strlen(key)); |
nothing calls this directly
no outgoing calls
no test coverage detected