diff options
author | Vicent Marti <tanoku@gmail.com> | 2010-05-23 04:41:31 +0200 |
---|---|---|
committer | Andreas Ericsson <ae@op5.se> | 2010-06-02 10:32:07 +0200 |
commit | a7c182c59414cece10c819989bce3f1247f4eacc (patch) | |
tree | 54bdf67864a5d9dc16fc548f2748462b3fb63697 /src/revobject.c | |
parent | d047b47aadf88501238f36f5c17dd0a50dc62087 (diff) | |
download | libgit2-a7c182c59414cece10c819989bce3f1247f4eacc.tar.gz |
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>
Diffstat (limited to 'src/revobject.c')
-rw-r--r-- | src/revobject.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/revobject.c b/src/revobject.c index 2ed634540..c6736542f 100644 --- a/src/revobject.c +++ b/src/revobject.c @@ -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]; |