summaryrefslogtreecommitdiff
path: root/oidset.h
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2017-09-29 22:54:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-10-01 08:18:03 (GMT)
commit9e6fabde82e91366a7fea5a81e795d26bbe7e10d (patch)
treeacaf49902bbb6a41be5883e6a183a98e05380ea5 /oidset.h
parentea220ee40cbb03a63ebad2be902057bf742492fd (diff)
downloadgit-9e6fabde82e91366a7fea5a81e795d26bbe7e10d.zip
git-9e6fabde82e91366a7fea5a81e795d26bbe7e10d.tar.gz
git-9e6fabde82e91366a7fea5a81e795d26bbe7e10d.tar.bz2
oidmap: map with OID as key
This is similar to using the hashmap in hashmap.c, but with an easier-to-use API. In particular, custom entry comparisons no longer need to be written, and lookups can be done without constructing a temporary entry structure. This is implemented as a thin wrapper over the hashmap API. In particular, this means that there is an additional 4-byte overhead due to the fact that the first 4 bytes of the hash is redundantly stored. For now, I'm taking the simpler approach, but if need be, we can reimplement oidmap without affecting the callers significantly. oidset has been updated to use oidmap. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'oidset.h')
-rw-r--r--oidset.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/oidset.h b/oidset.h
index b7eaab5..f4c9e0f 100644
--- a/oidset.h
+++ b/oidset.h
@@ -1,6 +1,8 @@
#ifndef OIDSET_H
#define OIDSET_H
+#include "oidmap.h"
+
/**
* This API is similar to sha1-array, in that it maintains a set of object ids
* in a memory-efficient way. The major differences are:
@@ -17,10 +19,10 @@
* A single oidset; should be zero-initialized (or use OIDSET_INIT).
*/
struct oidset {
- struct hashmap map;
+ struct oidmap map;
};
-#define OIDSET_INIT { { NULL } }
+#define OIDSET_INIT { OIDMAP_INIT }
/**
* Returns true iff `set` contains `oid`.