commit d6cf760a654df954418c577a08765155985c095d from: Stefan Sperling date: Fri Aug 16 15:00:52 2024 UTC move pack cache entries to front upon any access, not just when cache is full commit - e11883f02b06fcd5d68da0aa0b781f93b3e94568 commit + d6cf760a654df954418c577a08765155985c095d blob - 04437057664e089f746308bec4509bd46f5b790e blob + 361e253cad3dc219aabf23e9274ab69447d1af1e --- lib/repository.c +++ lib/repository.c @@ -1579,6 +1579,7 @@ got_repo_cache_pack(struct got_pack **packp, struct go { const struct got_error *err = NULL; struct got_pack *pack = NULL; + struct got_pack tmp; struct stat sb; size_t i; @@ -1594,7 +1595,6 @@ got_repo_cache_pack(struct got_pack **packp, struct go } if (i == repo->pack_cache_size) { - struct got_pack tmp; do { i--; } while (i > 0 && repo->pinned_pack >= 0 && @@ -1606,6 +1606,9 @@ got_repo_cache_pack(struct got_pack **packp, struct go return got_error_from_errno("ftruncate"); if (ftruncate(repo->packs[i].accumfd, 0L) == -1) return got_error_from_errno("ftruncate"); + } + + if (i != 0) { memcpy(&tmp, &repo->packs[i], sizeof(tmp)); memcpy(&repo->packs[i], &repo->packs[0], sizeof(repo->packs[i]));