Skip to content

Commit

Permalink
call init_pack_revindex() lazily
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nicolas Pitre authored and gitster committed Jun 24, 2008
1 parent 6b516d9 commit 1f5c74f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
2 changes: 0 additions & 2 deletions builtin-pack-objects.c
Expand Up @@ -1148,8 +1148,6 @@ static void get_object_details(void)
sorted_by_offset[i] = objects + i;
qsort(sorted_by_offset, nr_objects, sizeof(*sorted_by_offset), pack_offset_sort);

init_pack_revindex();

for (i = 0; i < nr_objects; i++)
check_object(sorted_by_offset[i]);

Expand Down
1 change: 0 additions & 1 deletion pack-check.c
Expand Up @@ -107,7 +107,6 @@ static void show_pack_info(struct packed_git *p)

nr_objects = p->num_objects;
memset(chain_histogram, 0, sizeof(chain_histogram));
init_pack_revindex();

for (i = 0; i < nr_objects; i++) {
const unsigned char *sha1;
Expand Down
6 changes: 4 additions & 2 deletions pack-revindex.c
Expand Up @@ -40,7 +40,7 @@ static int pack_revindex_ix(struct packed_git *p)
return -1 - i;
}

void init_pack_revindex(void)
static void init_pack_revindex(void)
{
int num;
struct packed_git *p;
Expand Down Expand Up @@ -118,9 +118,11 @@ struct revindex_entry *find_pack_revindex(struct packed_git *p, off_t ofs)
struct pack_revindex *rix;
struct revindex_entry *revindex;

if (!pack_revindex_hashsz)
init_pack_revindex();
num = pack_revindex_ix(p);
if (num < 0)
die("internal error: pack revindex uninitialized");
die("internal error: pack revindex fubar");

rix = &pack_revindex[num];
if (!rix->revindex)
Expand Down
1 change: 0 additions & 1 deletion pack-revindex.h
Expand Up @@ -6,7 +6,6 @@ struct revindex_entry {
unsigned int nr;
};

void init_pack_revindex(void);
struct revindex_entry *find_pack_revindex(struct packed_git *p, off_t ofs);

#endif

0 comments on commit 1f5c74f

Please sign in to comment.