hashmap: add simplified hashmap_get_from_hash() API
commitab73a9d119240b0b908ccb9edd19b8e536ce29b9
authorKarsten Blees <karsten.blees@gmail.com>
Wed, 2 Jul 2014 22:22:11 +0000 (3 00:22 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 7 Jul 2014 20:56:35 +0000 (7 13:56 -0700)
treed942c8d2777fa05d082819c998d64c7434ccec42
parentaa420c48eaea5c89946b8753363d09955300133f
hashmap: add simplified hashmap_get_from_hash() API

Hashmap entries are typically looked up by just a key. The hashmap_get()
API expects an initialized entry structure instead, to support compound
keys. This flexibility is currently only needed by find_dir_entry() in
name-hash.c (and compat/win32/fscache.c in the msysgit fork). All other
(currently five) call sites of hashmap_get() have to set up a near emtpy
entry structure, resulting in duplicate code like this:

  struct hashmap_entry keyentry;
  hashmap_entry_init(&keyentry, hash(key));
  return hashmap_get(map, &keyentry, key);

Add a hashmap_get_from_hash() API that allows hashmap lookups by just
specifying the key and its hash code, i.e.:

  return hashmap_get_from_hash(map, hash(key), key);

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/technical/api-hashmap.txt
builtin/describe.c
diffcore-rename.c
hashmap.h
name-hash.c
test-hashmap.c