commit - f6be5c308af39aaf5dd86f08ed270f009ba12ed8
commit + a9bf0c2c43fb5545d5929f63896d06d00281cdd7
blob - 4eb219f9241f6980f82035f28f5128cab0f988c5
blob + fbcf7b53c0bdfe9bb34535846550f44b0c38fbb1
--- lib/got_lib_repository.h
+++ lib/got_lib_repository.h
struct got_object_cache {
enum got_object_chache_type type;
struct got_object_idset *set;
- int ncached;
int cache_hit;
int cache_miss;
};
blob - 5900746421a52c01d51c4bbf365e42cce22e01f2
blob + a688bdaa5e2ba19b4cd1972d21e8d8d99c37f0e5
--- lib/repository.c
+++ lib/repository.c
{
const struct got_error *err = NULL;
struct got_object_cache_entry *ce;
+ int nelem;
- if (cache->ncached >= GOT_OBJECT_CACHE_SIZE) {
+ nelem = got_object_idset_num_elements(cache->set);
+ if (nelem >= GOT_OBJECT_CACHE_SIZE) {
err = got_object_idset_remove_random((void **)&ce,
cache->set);
if (err)
break;
}
free(ce);
- cache->ncached--;
}
ce = calloc(1, sizeof(*ce));
free(ce);
err = NULL;
}
- } else
- cache->ncached++;
+ }
return err;
}