Commit a7c182c5 by Vicent Marti Committed by Andreas Ericsson

Add object cache to the revision pool.

Fixed issue when generating pending commits list during iteration.

The 'git_commit_lookup' function will now check the pool's cache
for commits which have been previously loaded/parsed; there can only
be a single 'git_commit' structure for each commit on the same pool.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>
parent d047b47a
......@@ -57,6 +57,7 @@ unsigned int git_revpool_table__hash(const git_oid *id)
git_revpool_table *git_revpool_table_create(unsigned int min_size)
{
git_revpool_table *table;
int i;
table = git__malloc(sizeof(table));
......@@ -83,7 +84,8 @@ git_revpool_table *git_revpool_table_create(unsigned int min_size)
return NULL;
}
memset(table->nodes, 0x0, (min_size + 1) * sizeof(git_revpool_node *));
for (i = 0; i <= min_size; ++i)
table->nodes[i] = NULL;
return table;
}
......@@ -93,6 +95,9 @@ int git_revpool_table_insert(git_revpool_table *table, git_revpool_object *objec
git_revpool_node *node;
unsigned int index, hash;
if (table == NULL)
return -1;
if (table->count + 1 > table->max_count)
git_revpool_table_resize(table);
......@@ -118,6 +123,9 @@ git_revpool_object *git_revpool_table_lookup(git_revpool_table *table, const git
git_revpool_node *node;
unsigned int index, hash;
if (table == NULL)
return NULL;
hash = git_revpool_table__hash(id);
index = (hash & table->size_mask);
node = table->nodes[index];
......
......@@ -19,10 +19,11 @@ struct git_revpool_node
struct git_revpool_table
{
struct git_revpool_node **nodes;
unsigned int size_mask;
unsigned int count;
unsigned int max_count;
struct git_revpool_node **nodes;
};
......
......@@ -73,8 +73,6 @@ void gitrp_push(git_revpool *pool, git_commit *commit)
if (commit->uninteresting)
git_commit__mark_uninteresting(commit);
commit->seen = 1;
git_commit_list_append(&pool->roots, commit);
}
......@@ -84,38 +82,30 @@ void gitrp_hide(git_revpool *pool, git_commit *commit)
gitrp_push(pool, commit);
}
void gitrp_prepare_walk(git_revpool *pool)
void gitrp__enroot(git_revpool *pool, git_commit *commit)
{
git_commit_node *it;
git_commit_node *parents;
for (it = pool->roots.head; it != NULL; it = it->next)
{
git_commit_list_append(&pool->iterator, it->commit);
}
if (commit->seen)
return;
for (it = pool->iterator.head; it != NULL; it = it->next)
{
git_commit *commit;
git_commit_node *parents;
if (commit->parsed == 0)
git_commit_parse_existing(commit);
commit = it->commit;
parents = commit->parents.head;
commit->seen = 1;
while (parents)
{
git_commit *parent = parents->commit;
parents = parents->next;
for (parents = commit->parents.head; parents != NULL; parents = parents->next)
gitrp__enroot(pool, parents->commit);
if (parent->seen)
continue;
git_commit_list_append(&pool->iterator, commit);
}
if (parent->parsed == 0)
git_commit_parse_existing(parent);
void gitrp_prepare_walk(git_revpool *pool)
{
git_commit_node *it;
parent->seen = 1;
git_commit_list_append(&pool->iterator, parent);
}
}
for (it = pool->roots.head; it != NULL; it = it->next)
gitrp__enroot(pool, it->commit);
// TODO: topo sort, time sort
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment