Skip to content

Commit 8f1ff26

Browse files
committed
idxmap: remove GIT__USE_IDXMAP
1 parent cee9ca6 commit 8f1ff26

File tree

3 files changed

+14
-23
lines changed

3 files changed

+14
-23
lines changed

src/idxmap.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,20 @@
77

88
#include "idxmap.h"
99

10-
GIT__USE_IDXMAP
11-
GIT__USE_IDXMAP_ICASE
10+
/* This is __ac_X31_hash_string but with tolower and it takes the entry's stage into account */
11+
static kh_inline khint_t idxentry_hash(const git_index_entry *e)
12+
{
13+
const char *s = e->path;
14+
khint_t h = (khint_t)git__tolower(*s);
15+
if (h) for (++s ; *s; ++s) h = (h << 5) - h + (khint_t)git__tolower(*s);
16+
return h + GIT_IDXENTRY_STAGE(e);
17+
}
18+
19+
#define idxentry_equal(a, b) (GIT_IDXENTRY_STAGE(a) == GIT_IDXENTRY_STAGE(b) && strcmp(a->path, b->path) == 0)
20+
#define idxentry_icase_equal(a, b) (GIT_IDXENTRY_STAGE(a) == GIT_IDXENTRY_STAGE(b) && strcasecmp(a->path, b->path) == 0)
21+
22+
__KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal)
23+
__KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal)
1224

1325
int git_idxmap_alloc(git_idxmap **map)
1426
{

src/idxmap.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,6 @@ typedef khash_t(idxicase) git_idxmap_icase;
2626

2727
typedef khiter_t git_idxmap_iter;
2828

29-
/* This is __ac_X31_hash_string but with tolower and it takes the entry's stage into account */
30-
static kh_inline khint_t idxentry_hash(const git_index_entry *e)
31-
{
32-
const char *s = e->path;
33-
khint_t h = (khint_t)git__tolower(*s);
34-
if (h) for (++s ; *s; ++s) h = (h << 5) - h + (khint_t)git__tolower(*s);
35-
return h + GIT_IDXENTRY_STAGE(e);
36-
}
37-
38-
#define idxentry_equal(a, b) (GIT_IDXENTRY_STAGE(a) == GIT_IDXENTRY_STAGE(b) && strcmp(a->path, b->path) == 0)
39-
#define idxentry_icase_equal(a, b) (GIT_IDXENTRY_STAGE(a) == GIT_IDXENTRY_STAGE(b) && strcasecmp(a->path, b->path) == 0)
40-
41-
#define GIT__USE_IDXMAP \
42-
__KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal)
43-
44-
#define GIT__USE_IDXMAP_ICASE \
45-
__KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal)
46-
4729
int git_idxmap_alloc(git_idxmap **map);
4830
int git_idxmap_icase_alloc(git_idxmap_icase **map);
4931
void git_idxmap_insert(git_idxmap *map, const git_index_entry *key, void *value, int *rval);

src/index.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
#include "git2/config.h"
2828
#include "git2/sys/index.h"
2929

30-
GIT__USE_IDXMAP
31-
GIT__USE_IDXMAP_ICASE
32-
3330
#define INSERT_IN_MAP_EX(idx, map, e, err) do { \
3431
if ((idx)->ignore_case) \
3532
git_idxmap_icase_insert((khash_t(idxicase) *) (map), (e), (e), (err)); \

0 commit comments

Comments
 (0)