summaryrefslogtreecommitdiff
path: root/packfile.c
diff options
context:
space:
mode:
authorOlga Telezhnaya <olyatelezhnaya@gmail.com>2017-09-30 17:51:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-10-01 08:30:26 (GMT)
commit8865859dfc346c61f0e75fa429c5d307bd27368c (patch)
tree81b8f55f9ca4f3e4c523a5f2072feccf792e176e /packfile.c
parent20fed7cad40ed0b96232feb828129e3a2ee9860d (diff)
downloadgit-8865859dfc346c61f0e75fa429c5d307bd27368c.zip
git-8865859dfc346c61f0e75fa429c5d307bd27368c.tar.gz
git-8865859dfc346c61f0e75fa429c5d307bd27368c.tar.bz2
mru: use double-linked list from list.h
Simplify mru.[ch] and related code by reusing the double-linked list implementation from list.h instead of a custom one. This commit is an intermediate step. Our final goal is to get rid of mru.[ch] at all and inline all logic. Mentored-by: Christian Couder <christian.couder@gmail.com> Mentored by: Jeff King <peff@peff.net> Signed-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'packfile.c')
-rw-r--r--packfile.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/packfile.c b/packfile.c
index f69a5c8..502d915 100644
--- a/packfile.c
+++ b/packfile.c
@@ -40,7 +40,7 @@ static unsigned int pack_max_fds;
static size_t peak_pack_mapped;
static size_t pack_mapped;
struct packed_git *packed_git;
-struct mru packed_git_mru;
+struct mru packed_git_mru = {{&packed_git_mru.list, &packed_git_mru.list}};
#define SZ_FMT PRIuMAX
static inline uintmax_t sz_fmt(size_t s) { return s; }
@@ -1824,13 +1824,14 @@ static int fill_pack_entry(const unsigned char *sha1,
*/
int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
{
- struct mru_entry *p;
+ struct list_head *pos;
prepare_packed_git();
if (!packed_git)
return 0;
- for (p = packed_git_mru.head; p; p = p->next) {
+ list_for_each(pos, &packed_git_mru.list) {
+ struct mru *p = list_entry(pos, struct mru, list);
if (fill_pack_entry(sha1, e, p->item)) {
mru_mark(&packed_git_mru, p);
return 1;