diff options
| author | Russell Belfer <rb@github.com> | 2012-04-25 15:24:05 -0700 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2012-04-25 15:24:05 -0700 |
| commit | 3fc5c65d1a072fc727226cd66a1b096df4919da5 (patch) | |
| tree | 3d0a6a9d43c715d77b2c0b151ed344253011631d /src/cache.c | |
| parent | f50087c03b08230ba7d912e827a72e857128a7a8 (diff) | |
| parent | c2b670436f4cc8901811ae0348f3c56150d1ccd5 (diff) | |
| download | libgit2-3fc5c65d1a072fc727226cd66a1b096df4919da5.tar.gz | |
Merge pull request #642 from arrbee/mem-pools
Memory pools and khash hashtables
Diffstat (limited to 'src/cache.c')
| -rw-r--r-- | src/cache.c | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/cache.c b/src/cache.c index f445e906d..31da3c36e 100644 --- a/src/cache.c +++ b/src/cache.c @@ -9,21 +9,14 @@ #include "repository.h" #include "commit.h" #include "thread-utils.h" +#include "util.h" #include "cache.h" int git_cache_init(git_cache *cache, size_t size, git_cached_obj_freeptr free_ptr) { if (size < 8) size = 8; - - /* round up size to closest power of 2 */ - size--; - size |= size >> 1; - size |= size >> 2; - size |= size >> 4; - size |= size >> 8; - size |= size >> 16; - size++; + size = git__size_t_powerof2(size); cache->size_mask = size - 1; cache->lru_count = 0; |
