Merge branch 'jn/maint-fast-import-object-reuse' into maint

* jn/maint-fast-import-object-reuse:
  fast-import: insert new object entries at start of hash bucket
maint
Junio C Hamano 2011-01-19 08:25:46 -08:00
commit 267684f0b7
1 changed files with 2 additions and 7 deletions

View File

@ -539,22 +539,17 @@ static struct object_entry *insert_object(unsigned char *sha1)
{ {
unsigned int h = sha1[0] << 8 | sha1[1]; unsigned int h = sha1[0] << 8 | sha1[1];
struct object_entry *e = object_table[h]; struct object_entry *e = object_table[h];
struct object_entry *p = NULL;


while (e) { while (e) {
if (!hashcmp(sha1, e->idx.sha1)) if (!hashcmp(sha1, e->idx.sha1))
return e; return e;
p = e;
e = e->next; e = e->next;
} }


e = new_object(sha1); e = new_object(sha1);
e->next = NULL; e->next = object_table[h];
e->idx.offset = 0; e->idx.offset = 0;
if (p) object_table[h] = e;
p->next = e;
else
object_table[h] = e;
return e; return e;
} }