@matheusbsbs / matheus-bagliano / commits / 1f5c74f6cf
Fork 0

call init_pack_revindex() lazily

This makes life much easier for next patch, as well as being more efficient when the revindex is actually not used. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nicolas Pitre committed Jun 23, 2008 at 21:22 UTC 1f5c74f6cf918d317c73b328dcd4cf6f55c44d8a
4 files changed +4 -6
builtin-pack-objects.c
-2
@@ -1148,8 +1148,6 @@ static void get_object_details(void)
1148 sorted_by_offset[i] = objects + i;
1149 qsort(sorted_by_offset, nr_objects, sizeof(*sorted_by_offset), pack_offset_sort);
1150
1151 - init_pack_revindex();
1152 -
1151 for (i = 0; i < nr_objects; i++)
1152 check_object(sorted_by_offset[i]);
1153
pack-check.c
-1
@@ -107,7 +107,6 @@ static void show_pack_info(struct packed_git *p)
107
108 nr_objects = p->num_objects;
109 memset(chain_histogram, 0, sizeof(chain_histogram));
110 - init_pack_revindex();
110
111 for (i = 0; i < nr_objects; i++) {
112 const unsigned char *sha1;
pack-revindex.c
+4 -2
@@ -40,7 +40,7 @@ static int pack_revindex_ix(struct packed_git *p)
40 return -1 - i;
41 }
42
43 -void init_pack_revindex(void)
43 +static void init_pack_revindex(void)
44 {
45 int num;
46 struct packed_git *p;
@@ -118,9 +118,11 @@ struct revindex_entry *find_pack_revindex(struct packed_git *p, off_t ofs)
118 struct pack_revindex *rix;
119 struct revindex_entry *revindex;
120
121 + if (!pack_revindex_hashsz)
122 + init_pack_revindex();
123 num = pack_revindex_ix(p);
124 if (num < 0)
123 - die("internal error: pack revindex uninitialized");
125 + die("internal error: pack revindex fubar");
126
127 rix = &pack_revindex[num];
128 if (!rix->revindex)
pack-revindex.h
-1
@@ -6,7 +6,6 @@ struct revindex_entry {
6 unsigned int nr;
7 };
8
9 -void init_pack_revindex(void);
9 struct revindex_entry *find_pack_revindex(struct packed_git *p, off_t ofs);
10
11 #endif