Skip to content
  • Karsten Blees's avatar
    hashmap: add simplified hashmap_get_from_hash() API · ab73a9d1
    Karsten Blees authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    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: default avatarKarsten Blees <blees@dcon.de>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    ab73a9d1