| 1 |
|
| /* |
| 2 |
|
| * Copyright (C) the libgit2 contributors. All rights reserved. |
| 3 |
|
| * |
| 4 |
|
| * This file is part of libgit2, distributed under the GNU GPL v2 with |
| 5 |
|
| * a Linking Exception. For full terms see the included COPYING file. |
| 6 |
|
| */ |
| 7 |
|
| |
| 8 |
|
| #include "idxmap.h" |
| 9 |
|
| |
| 10 |
|
| #define kmalloc git__malloc |
| 11 |
|
| #define kcalloc git__calloc |
| 12 |
|
| #define krealloc git__realloc |
| 13 |
|
| #define kreallocarray git__reallocarray |
| 14 |
|
| #define kfree git__free |
| 15 |
|
| #include "khash.h" |
| 16 |
|
| |
| 17 |
|
| __KHASH_TYPE(idx, const git_index_entry *, git_index_entry *) |
| 18 |
|
| __KHASH_TYPE(idxicase, const git_index_entry *, git_index_entry *) |
| 19 |
|
| |
| 20 |
|
| /* This is __ac_X31_hash_string but with tolower and it takes the entry's stage into account */ |
| 21 |
601 |
| static kh_inline khint_t idxentry_hash(const git_index_entry *e) |
| 22 |
|
| { |
| 23 |
601 |
| const char *s = e->path; |
| 24 |
601 |
| khint_t h = (khint_t)git__tolower(*s); |
| 25 |
4844 |
▶ | if (h) for (++s ; *s; ++s) h = (h << 5) - h + (khint_t)git__tolower(*s); |
Branch: 2 branches
| Branch | True | False | Total |
| if (h) for (++s ; *s; ++s) h = (h << 5) - h + (khint_t)git__tolower(*s); |
601 |
0 |
601 |
| if (h) for (++s ; *s; ++s) h = (h << 5) - h + (khint_t)git__tolower(*s); |
4243 |
601 |
4844 |
|
| 26 |
601 |
| return h + GIT_INDEX_ENTRY_STAGE(e); |
| 27 |
|
| } |
| 28 |
|
| |
| 29 |
|
| #define idxentry_equal(a, b) (GIT_INDEX_ENTRY_STAGE(a) == GIT_INDEX_ENTRY_STAGE(b) && strcmp(a->path, b->path) == 0) |
| 30 |
|
| #define idxentry_icase_equal(a, b) (GIT_INDEX_ENTRY_STAGE(a) == GIT_INDEX_ENTRY_STAGE(b) && strcasecmp(a->path, b->path) == 0) |
| 31 |
|
| |
| 32 |
1110 |
▶ | __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
Branch: 44 branches
| Branch | True | False | Total |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
27 |
0 |
27 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
27 |
0 |
27 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
25 |
148 |
173 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
1 |
24 |
25 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
0 |
1 |
1 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
0 |
24 |
24 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
141 |
32 |
173 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
12 |
40 |
52 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
0 |
52 |
52 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
52 |
32 |
84 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
12 |
40 |
52 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
7 |
33 |
40 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
33 |
0 |
33 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
32 |
0 |
32 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
32 |
0 |
32 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
7 |
25 |
32 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
166 |
7 |
173 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
7 |
0 |
7 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
33 |
35 |
68 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
0 |
68 |
68 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
1 |
67 |
68 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
0 |
68 |
68 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
1 |
67 |
68 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
66 |
2 |
68 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
0 |
66 |
66 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
0 |
66 |
66 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
68 |
0 |
68 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
35 |
33 |
68 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
6 |
38 |
44 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
30 |
8 |
38 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
3 |
27 |
30 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
68 |
68 |
136 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
1 |
67 |
68 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
390 |
9 |
399 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
0 |
135 |
135 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
321 |
204 |
525 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
39 |
282 |
321 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
15 |
267 |
282 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
81 |
186 |
267 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
204 |
186 |
390 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
71 |
0 |
71 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
54 |
17 |
71 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
1 |
53 |
54 |
| __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) |
54 |
0 |
54 |
|
| 33 |
0 |
▶ | __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
Branch: 44 branches
| Branch | True | False | Total |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
| __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) |
0 |
0 |
0 |
|
| 34 |
|
| |
| 35 |
54 |
| int git_idxmap_new(git_idxmap **out) |
| 36 |
|
| { |
| 37 |
54 |
| *out = kh_init(idx); |
| 38 |
54 |
▶ | GIT_ERROR_CHECK_ALLOC(*out); |
Branch: 1 branch
| Branch | True | False | Total |
| GIT_ERROR_CHECK_ALLOC(*out); |
0 |
54 |
54 |
|
| 39 |
|
| |
| 40 |
54 |
| return 0; |
| 41 |
|
| } |
| 42 |
|
| |
| 43 |
0 |
| int git_idxmap_icase_new(git_idxmap_icase **out) |
| 44 |
|
| { |
| 45 |
0 |
| *out = kh_init(idxicase); |
| 46 |
0 |
▶ | GIT_ERROR_CHECK_ALLOC(*out); |
Branch: 1 branch
| Branch | True | False | Total |
| GIT_ERROR_CHECK_ALLOC(*out); |
0 |
0 |
0 |
|
| 47 |
|
| |
| 48 |
0 |
| return 0; |
| 49 |
|
| } |
| 50 |
|
| |
| 51 |
54 |
| void git_idxmap_free(git_idxmap *map) |
| 52 |
|
| { |
| 53 |
54 |
| kh_destroy(idx, map); |
| 54 |
54 |
| } |
| 55 |
|
| |
| 56 |
0 |
| void git_idxmap_icase_free(git_idxmap_icase *map) |
| 57 |
|
| { |
| 58 |
0 |
| kh_destroy(idxicase, map); |
| 59 |
0 |
| } |
| 60 |
|
| |
| 61 |
71 |
| void git_idxmap_clear(git_idxmap *map) |
| 62 |
|
| { |
| 63 |
71 |
| kh_clear(idx, map); |
| 64 |
71 |
| } |
| 65 |
|
| |
| 66 |
0 |
| void git_idxmap_icase_clear(git_idxmap_icase *map) |
| 67 |
|
| { |
| 68 |
0 |
| kh_clear(idxicase, map); |
| 69 |
0 |
| } |
| 70 |
|
| |
| 71 |
43 |
| int git_idxmap_resize(git_idxmap *map, size_t size) |
| 72 |
|
| { |
| 73 |
86 |
| if (!git__is_uint32(size) || |
| 74 |
43 |
| kh_resize(idx, map, (khiter_t)size) < 0) { |
| 75 |
0 |
| git_error_set_oom(); |
| 76 |
0 |
| return -1; |
| 77 |
|
| } |
| 78 |
43 |
| return 0; |
| 79 |
|
| } |
| 80 |
|
| |
| 81 |
0 |
| int git_idxmap_icase_resize(git_idxmap_icase *map, size_t size) |
| 82 |
|
| { |
| 83 |
0 |
| if (!git__is_uint32(size) || |
| 84 |
0 |
| kh_resize(idxicase, map, (khiter_t)size) < 0) { |
| 85 |
0 |
| git_error_set_oom(); |
| 86 |
0 |
| return -1; |
| 87 |
|
| } |
| 88 |
0 |
| return 0; |
| 89 |
|
| } |
| 90 |
|
| |
| 91 |
182 |
| void *git_idxmap_get(git_idxmap *map, const git_index_entry *key) |
| 92 |
|
| { |
| 93 |
182 |
| size_t idx = kh_get(idx, map, key); |
| 94 |
182 |
▶ | if (idx == kh_end(map) || !kh_exist(map, idx)) |
Branch: 2 branches
| Branch | True | False | Total |
| if (idx == kh_end(map) || !kh_exist(map, idx)) |
159 |
23 |
182 |
| if (idx == kh_end(map) || !kh_exist(map, idx)) |
0 |
159 |
159 |
|
| 95 |
23 |
| return NULL; |
| 96 |
159 |
| return kh_val(map, idx); |
| 97 |
|
| } |
| 98 |
|
| |
| 99 |
173 |
| int git_idxmap_set(git_idxmap *map, const git_index_entry *key, void *value) |
| 100 |
|
| { |
| 101 |
|
| size_t idx; |
| 102 |
|
| int rval; |
| 103 |
|
| |
| 104 |
173 |
| idx = kh_put(idx, map, key, &rval); |
| 105 |
173 |
▶ | if (rval < 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (rval < 0) |
0 |
173 |
173 |
|
| 106 |
0 |
| return -1; |
| 107 |
|
| |
| 108 |
173 |
▶ | if (rval == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (rval == 0) |
0 |
173 |
173 |
|
| 109 |
0 |
| kh_key(map, idx) = key; |
| 110 |
|
| |
| 111 |
173 |
| kh_val(map, idx) = value; |
| 112 |
|
| |
| 113 |
173 |
| return 0; |
| 114 |
|
| } |
| 115 |
|
| |
| 116 |
0 |
| int git_idxmap_icase_set(git_idxmap_icase *map, const git_index_entry *key, void *value) |
| 117 |
|
| { |
| 118 |
|
| size_t idx; |
| 119 |
|
| int rval; |
| 120 |
|
| |
| 121 |
0 |
| idx = kh_put(idxicase, map, key, &rval); |
| 122 |
0 |
▶ | if (rval < 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (rval < 0) |
0 |
0 |
0 |
|
| 123 |
0 |
| return -1; |
| 124 |
|
| |
| 125 |
0 |
▶ | if (rval == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (rval == 0) |
0 |
0 |
0 |
|
| 126 |
0 |
| kh_key(map, idx) = key; |
| 127 |
|
| |
| 128 |
0 |
| kh_val(map, idx) = value; |
| 129 |
|
| |
| 130 |
0 |
| return 0; |
| 131 |
|
| } |
| 132 |
|
| |
| 133 |
0 |
| void *git_idxmap_icase_get(git_idxmap_icase *map, const git_index_entry *key) |
| 134 |
|
| { |
| 135 |
0 |
| size_t idx = kh_get(idxicase, map, key); |
| 136 |
0 |
▶ | if (idx == kh_end(map) || !kh_exist(map, idx)) |
Branch: 2 branches
| Branch | True | False | Total |
| if (idx == kh_end(map) || !kh_exist(map, idx)) |
0 |
0 |
0 |
| if (idx == kh_end(map) || !kh_exist(map, idx)) |
0 |
0 |
0 |
|
| 137 |
0 |
| return NULL; |
| 138 |
0 |
| return kh_val(map, idx); |
| 139 |
|
| } |
| 140 |
|
| |
| 141 |
217 |
| int git_idxmap_delete(git_idxmap *map, const git_index_entry *key) |
| 142 |
|
| { |
| 143 |
217 |
| khiter_t idx = kh_get(idx, map, key); |
| 144 |
217 |
▶ | if (idx == kh_end(map)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (idx == kh_end(map)) |
190 |
27 |
217 |
|
| 145 |
190 |
| return GIT_ENOTFOUND; |
| 146 |
27 |
| kh_del(idx, map, idx); |
| 147 |
27 |
| return 0; |
| 148 |
|
| } |
| 149 |
|
| |
| 150 |
0 |
| int git_idxmap_icase_delete(git_idxmap_icase *map, const git_index_entry *key) |
| 151 |
|
| { |
| 152 |
0 |
| khiter_t idx = kh_get(idxicase, map, key); |
| 153 |
0 |
▶ | if (idx == kh_end(map)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (idx == kh_end(map)) |
0 |
0 |
0 |
|
| 154 |
0 |
| return GIT_ENOTFOUND; |
| 155 |
0 |
| kh_del(idxicase, map, idx); |
| 156 |
0 |
| return 0; |
| 157 |
|
| } |