commit 6d921bc281f87405ca22c72c97fd7db2b6f2c977 from: Stefan Sperling via: Thomas Adam date: Fri Aug 16 15:31:13 2024 UTC move pack cache entries to front upon any access, not just when cache is full commit - 3aa55f1085484754656826a13fbb625b01dd06b4 commit + 6d921bc281f87405ca22c72c97fd7db2b6f2c977 blob - 51f4532d94bf8d5b7cfcfad6123084e02a55f82f blob + 9a55e34a2f2a82ef53f2924e38bce6265f880bb1 --- lib/repository.c +++ lib/repository.c @@ -1576,6 +1576,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; @@ -1591,7 +1592,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 && @@ -1603,6 +1603,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]));