]> git.proxmox.com Git - libgit2.git/commitdiff
khash: avoid using `kh_size` directly
authorPatrick Steinhardt <ps@pks.im>
Wed, 25 Jan 2017 13:05:24 +0000 (14:05 +0100)
committerPatrick Steinhardt <ps@pks.im>
Fri, 17 Feb 2017 10:41:06 +0000 (11:41 +0100)
src/cache.c
src/cache.h
src/submodule.c

index 16ae9b397dd39c27022b8255c9beca439ad1c161..e8fd207b16d56fc6c9aae6cde60ba56ff23dbf12 100644 (file)
@@ -47,11 +47,11 @@ void git_cache_dump_stats(git_cache *cache)
 {
        git_cached_obj *object;
 
-       if (kh_size(cache->map) == 0)
+       if (git_cache_size(cache) == 0)
                return;
 
-       printf("Cache %p: %d items cached, %"PRIdZ" bytes\n",
-               cache, kh_size(cache->map), cache->used_memory);
+       printf("Cache %p: %"PRIuZ" items cached, %"PRIdZ" bytes\n",
+               cache, git_cache_size(cache), cache->used_memory);
 
        kh_foreach_value(cache->map, object, {
                char oid_str[9];
@@ -81,7 +81,7 @@ static void clear_cache(git_cache *cache)
 {
        git_cached_obj *evict = NULL;
 
-       if (kh_size(cache->map) == 0)
+       if (git_cache_size(cache) == 0)
                return;
 
        kh_foreach_value(cache->map, evict, {
@@ -119,7 +119,7 @@ static void cache_evict_entries(git_cache *cache)
        ssize_t evicted_memory = 0;
 
        /* do not infinite loop if there's not enough entries to evict  */
-       if (evict_count > kh_size(cache->map)) {
+       if (evict_count > git_cache_size(cache)) {
                clear_cache(cache);
                return;
        }
index 697123739795c937ebad58342d1443926881347d..0f0bfcf5d4dede78792a357420d6545ed3c50ce2 100644 (file)
@@ -53,7 +53,7 @@ void *git_cache_get_any(git_cache *cache, const git_oid *oid);
 
 GIT_INLINE(size_t) git_cache_size(git_cache *cache)
 {
-       return (size_t)kh_size(cache->map);
+       return (size_t)git_oidmap_size(cache->map);
 }
 
 GIT_INLINE(void) git_cached_obj_incref(void *_obj)
index 3007d25df04bbc5886fc620e97ade4792a3cb6d8..0bc25cc29dc8c93cea29c9b17dfe23836cfebd90 100644 (file)
@@ -555,7 +555,7 @@ int git_submodule_foreach(
                goto done;
 
        if (!(error = git_vector_init(
-                       &snapshot, kh_size(submodules), submodule_cmp))) {
+                       &snapshot, git_strmap_num_entries(submodules), submodule_cmp))) {
 
                git_strmap_foreach_value(submodules, sm, {
                        if ((error = git_vector_insert(&snapshot, sm)) < 0)