commit - 10a623dfc23b47f494941e0eac741420c08372a3
commit + 7a0b1068b1c1dc1680f5dc45b7a4ea1e9d8a9b9e
blob - 17697cc62656dd554d17df6ee00a548fde19f6e9
blob + f216e0867a7738383ffc5b34e5923ad33c16f541
--- lib/repository.c
+++ lib/repository.c
}
}
if (i == repo->pack_cache_size) {
- err = got_packidx_close(repo->packidx_cache[i - 1]);
+ i = repo->pack_cache_size - 1;
+ err = got_packidx_close(repo->packidx_cache[i]);
if (err)
return err;
}
- /*
- * Insert the new pack index at the front so it will
- * be searched first in the future.
- */
- memmove(&repo->packidx_cache[1], &repo->packidx_cache[0],
- sizeof(repo->packidx_cache) -
- sizeof(repo->packidx_cache[0]));
- repo->packidx_cache[0] = packidx;
+ repo->packidx_cache[i] = packidx;
return NULL;
}
* searching a wrong pack index can be expensive.
*/
if (i > 0) {
- struct got_packidx *p;
- p = repo->packidx_cache[0];
+ memmove(&repo->packidx_cache[1],
+ &repo->packidx_cache[0],
+ i * sizeof(repo->packidx_cache[0]));
repo->packidx_cache[0] = *packidx;
- repo->packidx_cache[i] = p;
}
return NULL;
}