Thread (26 messages) flat view 26 messages, 5 authors, 2018-08-06

Re: [RFC PATCH 2/5] Add delta-islands.{c,h}

From: Jeff King <hidden>
Date: 2018-07-27 09:40:29

On Sun, Jul 22, 2018 at 07:48:33AM +0200, Christian Couder wrote:
+	/*
+	 * We process only trees, as commits and tags have already been handled
+	 * (and passed their marks on to root trees, as well. We must make sure
+	 * to process them in descending tree-depth order so that marks
+	 * propagate down the tree properly, even if a sub-tree is found in
+	 * multiple parent trees.
+	 */
+	todo = xmalloc(to_pack->nr_objects * sizeof(*todo));
I was fiddling with "make coccicheck", and it looks like this code could
stand some modernization. This could use ALLOC_ARRAY().
+	for (i = 0; i < to_pack->nr_objects; i++) {
+		if (oe_type(&to_pack->objects[i]) == OBJ_TREE)
+			todo[nr++] = &to_pack->objects[i];
+	}
+	qsort(todo, nr, sizeof(*todo), cmp_tree_depth);
And this QSORT().

There are a few others, I won't list them all. The only tricky one I see
is:
+		free(tree->buffer);
+		tree->buffer = NULL;
+		tree->object.parsed = 0;
This suggests FREE_AND_NULL(), but I think it actually the whole block
should become a call to free_tree_buffer().

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help