Skip to content

Commit 8676223

Browse files
committed
Merge branch 'gs/retire-mru'
Retire mru API as it does not give enough abstraction over underlying list API to be worth it. * gs/retire-mru: mru: Replace mru.[ch] with list.h implementation
2 parents afc8aa3 + ec2dd32 commit 8676223

File tree

7 files changed

+17
-86
lines changed

7 files changed

+17
-86
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,6 @@ LIB_OBJS += merge.o
831831
LIB_OBJS += merge-blobs.o
832832
LIB_OBJS += merge-recursive.o
833833
LIB_OBJS += mergesort.o
834-
LIB_OBJS += mru.o
835834
LIB_OBJS += name-hash.o
836835
LIB_OBJS += notes.o
837836
LIB_OBJS += notes-cache.o

builtin/pack-objects.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "reachable.h"
2727
#include "sha1-array.h"
2828
#include "argv-array.h"
29-
#include "mru.h"
29+
#include "list.h"
3030
#include "packfile.h"
3131

3232
static const char *pack_usage[] = {
@@ -1026,9 +1026,8 @@ static int want_object_in_pack(const struct object_id *oid,
10261026
return want;
10271027
}
10281028

1029-
list_for_each(pos, &packed_git_mru.list) {
1030-
struct mru *entry = list_entry(pos, struct mru, list);
1031-
struct packed_git *p = entry->item;
1029+
list_for_each(pos, &packed_git_mru) {
1030+
struct packed_git *p = list_entry(pos, struct packed_git, mru);
10321031
off_t offset;
10331032

10341033
if (p == *found_pack)
@@ -1045,7 +1044,7 @@ static int want_object_in_pack(const struct object_id *oid,
10451044
}
10461045
want = want_found_object(exclude, p);
10471046
if (!exclude && want > 0)
1048-
mru_mark(&packed_git_mru, entry);
1047+
list_move(&p->mru, &packed_git_mru);
10491048
if (want != -1)
10501049
return want;
10511050
}

cache.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "git-compat-util.h"
55
#include "strbuf.h"
66
#include "hashmap.h"
7-
#include "mru.h"
7+
#include "list.h"
88
#include "advice.h"
99
#include "gettext.h"
1010
#include "convert.h"
@@ -1638,6 +1638,7 @@ struct pack_window {
16381638

16391639
extern struct packed_git {
16401640
struct packed_git *next;
1641+
struct list_head mru;
16411642
struct pack_window *windows;
16421643
off_t pack_size;
16431644
const void *index_data;
@@ -1660,10 +1661,9 @@ extern struct packed_git {
16601661
} *packed_git;
16611662

16621663
/*
1663-
* A most-recently-used ordered version of the packed_git list, which can
1664-
* be iterated instead of packed_git (and marked via mru_mark).
1664+
* A most-recently-used ordered version of the packed_git list.
16651665
*/
1666-
extern struct mru packed_git_mru;
1666+
extern struct list_head packed_git_mru;
16671667

16681668
struct pack_entry {
16691669
off_t offset;

mru.c

Lines changed: 0 additions & 27 deletions
This file was deleted.

mru.h

Lines changed: 0 additions & 40 deletions
This file was deleted.

packfile.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "cache.h"
2-
#include "mru.h"
2+
#include "list.h"
33
#include "pack.h"
44
#include "dir.h"
55
#include "mergesort.h"
@@ -45,7 +45,7 @@ static unsigned int pack_max_fds;
4545
static size_t peak_pack_mapped;
4646
static size_t pack_mapped;
4747
struct packed_git *packed_git;
48-
struct mru packed_git_mru = {{&packed_git_mru.list, &packed_git_mru.list}};
48+
LIST_HEAD(packed_git_mru);
4949

5050
#define SZ_FMT PRIuMAX
5151
static inline uintmax_t sz_fmt(size_t s) { return s; }
@@ -876,9 +876,10 @@ static void prepare_packed_git_mru(void)
876876
{
877877
struct packed_git *p;
878878

879-
mru_clear(&packed_git_mru);
879+
INIT_LIST_HEAD(&packed_git_mru);
880+
880881
for (p = packed_git; p; p = p->next)
881-
mru_append(&packed_git_mru, p);
882+
list_add_tail(&p->mru, &packed_git_mru);
882883
}
883884

884885
static int prepare_packed_git_run_once = 0;
@@ -1847,10 +1848,10 @@ int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
18471848
if (!packed_git)
18481849
return 0;
18491850

1850-
list_for_each(pos, &packed_git_mru.list) {
1851-
struct mru *p = list_entry(pos, struct mru, list);
1852-
if (fill_pack_entry(sha1, e, p->item)) {
1853-
mru_mark(&packed_git_mru, p);
1851+
list_for_each(pos, &packed_git_mru) {
1852+
struct packed_git *p = list_entry(pos, struct packed_git, mru);
1853+
if (fill_pack_entry(sha1, e, p)) {
1854+
list_move(&p->mru, &packed_git_mru);
18541855
return 1;
18551856
}
18561857
}

sha1_file.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "bulk-checkin.h"
2525
#include "streaming.h"
2626
#include "dir.h"
27-
#include "mru.h"
2827
#include "list.h"
2928
#include "mergesort.h"
3029
#include "quote.h"

0 commit comments

Comments
 (0)