Commit 2b2ca9f01de591f1cf0cca17acf742542233b152

Stefan Sperling 2018-01-13T12:32:35

call got_object_id_cmp() just once in got_object_idx()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/lib/pack.c b/lib/pack.c
index e5e1540..1d72c45 100644
--- a/lib/pack.c
+++ b/lib/pack.c
@@ -294,10 +294,11 @@ get_object_idx(struct got_packidx_v2_hdr *packidx, struct got_object_id *id)
 	while (i < totobj) {
 		struct got_object_id *oid = &packidx->sorted_ids[i++];
 		uint32_t offset;
+		int cmp = got_object_id_cmp(id, oid);
 
-		if (got_object_id_cmp(id, oid) < 0)
+		if (cmp < 0)
 			continue;
-		if (got_object_id_cmp(id, oid) > 0)
+		if (cmp > 0)
 			break;
 
 		return i;