summaryrefslogtreecommitdiff
path: root/src/idxmap.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-02-02 13:09:32 +0100
committerPatrick Steinhardt <ps@pks.im>2017-02-17 11:41:06 +0100
commit8f1ff26bd3c46d7f4f20b6776fd2edac647f3335 (patch)
tree3810eea20d5acbb373c34874cf115cb01998f1d6 /src/idxmap.c
parentcee9ca6609466c63886218290e9ecad5f703094b (diff)
downloadlibgit2-8f1ff26bd3c46d7f4f20b6776fd2edac647f3335.tar.gz
idxmap: remove GIT__USE_IDXMAP
Diffstat (limited to 'src/idxmap.c')
-rw-r--r--src/idxmap.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/idxmap.c b/src/idxmap.c
index 490824017..10f55ad39 100644
--- a/src/idxmap.c
+++ b/src/idxmap.c
@@ -7,8 +7,20 @@
#include "idxmap.h"
-GIT__USE_IDXMAP
-GIT__USE_IDXMAP_ICASE
+/* This is __ac_X31_hash_string but with tolower and it takes the entry's stage into account */
+static kh_inline khint_t idxentry_hash(const git_index_entry *e)
+{
+ const char *s = e->path;
+ khint_t h = (khint_t)git__tolower(*s);
+ if (h) for (++s ; *s; ++s) h = (h << 5) - h + (khint_t)git__tolower(*s);
+ return h + GIT_IDXENTRY_STAGE(e);
+}
+
+#define idxentry_equal(a, b) (GIT_IDXENTRY_STAGE(a) == GIT_IDXENTRY_STAGE(b) && strcmp(a->path, b->path) == 0)
+#define idxentry_icase_equal(a, b) (GIT_IDXENTRY_STAGE(a) == GIT_IDXENTRY_STAGE(b) && strcasecmp(a->path, b->path) == 0)
+
+__KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal)
+__KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal)
int git_idxmap_alloc(git_idxmap **map)
{