mru: Replace mru.[ch] with list.h implementation
Replace the custom calls to mru.[ch] with calls to list.h. This patch is the final step in removing the mru API completely and inlining the logic. This patch leads to significant code reduction and the mru API hence, is not a useful abstraction anymore. Signed-off-by: Gargi Sharma <gs051095@gmail.com> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
8865859dfc
commit
ec2dd32c70
17
packfile.c
17
packfile.c
@ -1,5 +1,5 @@
|
||||
#include "cache.h"
|
||||
#include "mru.h"
|
||||
#include "list.h"
|
||||
#include "pack.h"
|
||||
#include "dir.h"
|
||||
#include "mergesort.h"
|
||||
@ -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 = {{&packed_git_mru.list, &packed_git_mru.list}};
|
||||
LIST_HEAD(packed_git_mru);
|
||||
|
||||
#define SZ_FMT PRIuMAX
|
||||
static inline uintmax_t sz_fmt(size_t s) { return s; }
|
||||
@ -859,9 +859,10 @@ static void prepare_packed_git_mru(void)
|
||||
{
|
||||
struct packed_git *p;
|
||||
|
||||
mru_clear(&packed_git_mru);
|
||||
INIT_LIST_HEAD(&packed_git_mru);
|
||||
|
||||
for (p = packed_git; p; p = p->next)
|
||||
mru_append(&packed_git_mru, p);
|
||||
list_add_tail(&p->mru, &packed_git_mru);
|
||||
}
|
||||
|
||||
static int prepare_packed_git_run_once = 0;
|
||||
@ -1830,10 +1831,10 @@ int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
|
||||
if (!packed_git)
|
||||
return 0;
|
||||
|
||||
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);
|
||||
list_for_each(pos, &packed_git_mru) {
|
||||
struct packed_git *p = list_entry(pos, struct packed_git, mru);
|
||||
if (fill_pack_entry(sha1, e, p)) {
|
||||
list_move(&p->mru, &packed_git_mru);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user