summaryrefslogtreecommitdiff
path: root/revision.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2013-05-25 11:08:09 +0200
committerJunio C Hamano <gitster@pobox.com>2013-05-28 09:25:01 -0700
commitbe6754c67f5aff02e9528116d06890391524f48e (patch)
tree5414b9742645e55115e396a80e00529e8b2a097b /revision.c
parentaeb4a51ef82c71c9a65d11f77aeedb53bea0e983 (diff)
downloadgit-be6754c67f5aff02e9528116d06890391524f48e.tar.gz
revision: use object_array_filter() in implementation of gc_boundary()
Use object_array_filter(), which will soon be made smarter about cleaning up discarded entries properly. Also add a function comment. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.c')
-rw-r--r--revision.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/revision.c b/revision.c
index 8ac88d6798..be73cb46c9 100644
--- a/revision.c
+++ b/revision.c
@@ -2435,25 +2435,23 @@ static struct commit *get_revision_1(struct rev_info *revs)
return NULL;
}
-static void gc_boundary(struct object_array *array)
+/*
+ * Return true for entries that have not yet been shown. (This is an
+ * object_array_each_func_t.)
+ */
+static int entry_unshown(struct object_array_entry *entry, void *cb_data_unused)
{
- unsigned nr = array->nr;
- unsigned alloc = array->alloc;
- struct object_array_entry *objects = array->objects;
+ return !(entry->item->flags & SHOWN);
+}
- if (alloc <= nr) {
- unsigned i, j;
- for (i = j = 0; i < nr; i++) {
- if (objects[i].item->flags & SHOWN)
- continue;
- if (i != j)
- objects[j] = objects[i];
- j++;
- }
- for (i = j; i < nr; i++)
- objects[i].item = NULL;
- array->nr = j;
- }
+/*
+ * If array is on the verge of a realloc, garbage-collect any entries
+ * that have already been shown to try to free up some space.
+ */
+static void gc_boundary(struct object_array *array)
+{
+ if (array->nr == array->alloc)
+ object_array_filter(array, entry_unshown, NULL);
}
static void create_boundary_commit_list(struct rev_info *revs)