Thread (14 messages) flat view 14 messages, 3 authors, 2018-08-12

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

From: SZEDER Gábor <hidden>
Date: 2018-08-11 09:04:35

quoted hunk ↗ jump to hunk
diff --git a/delta-islands.c b/delta-islands.c
new file mode 100644
index 0000000000..448ddcbbe4
--- /dev/null
+++ b/delta-islands.c
+static void deduplicate_islands(void)
+{
+	struct remote_island *island, *core = NULL, **list;
+	unsigned int island_count, dst, src, ref, i = 0;
+
+	island_count = kh_size(remote_islands);
+	list = xmalloc(island_count * sizeof(struct remote_island *));
Please use ALLOC_ARRAY here.
+
+	kh_foreach_value(remote_islands, island, {
+		list[i++] = island;
+	});
+
+	for (ref = 0; ref + 1 < island_count; ref++) {
+		for (src = ref + 1, dst = src; src < island_count; src++) {
+			if (list[ref]->hash == list[src]->hash)
+				continue;
+
+			if (src != dst)
+				list[dst] = list[src];
+
+			dst++;
+		}
+		island_count = dst;
+	}
+
+	island_bitmap_size = (island_count / 32) + 1;
+	core = get_core_island();
+
+	for (i = 0; i < island_count; ++i) {
+		mark_remote_island_1(list[i], core && list[i]->hash == core->hash);
+	}
+
+	free(list);
+}
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help