]> git.ipfire.org Git - thirdparty/git.git/commitdiff
more oideq/hasheq conversions
authorJeff King <peff@peff.net>
Tue, 2 Oct 2018 21:19:21 +0000 (17:19 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 4 Oct 2018 10:42:48 +0000 (03:42 -0700)
We added faster equality-comparison functions for hashes in
14438c4497 (introduce hasheq() and oideq(), 2018-08-28). A
few topics were in-flight at the time, and can now be
converted. This covers all spots found by "make coccicheck"
in master (the coccicheck results were tweaked by hand for
style).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/checkout.c
cache-tree.c
commit-reach.c
midx.c

index b30b48767e54a93f18ef0d341a04f14cc390e9a9..902c06702c62258384692f94ed6b55ecf6381a4e 100644 (file)
@@ -497,7 +497,8 @@ static int skip_merge_working_tree(const struct checkout_opts *opts,
         * We must do the merge if we are actually moving to a new commit.
         */
        if (!old_branch_info->commit || !new_branch_info->commit ||
-               oidcmp(&old_branch_info->commit->object.oid, &new_branch_info->commit->object.oid))
+               !oideq(&old_branch_info->commit->object.oid,
+                      &new_branch_info->commit->object.oid))
                return 0;
 
        /*
index 5ce51468f0b402fd2121e2c8b51ff12703d431ba..9c5cf2cc4fdc1f2f4ccc7f352289fe0ec75e8f5d 100644 (file)
@@ -781,7 +781,7 @@ static void verify_one(struct index_state *istate,
                strbuf_add(&tree_buf, oid->hash, the_hash_algo->rawsz);
        }
        hash_object_file(tree_buf.buf, tree_buf.len, tree_type, &new_oid);
-       if (oidcmp(&new_oid, &it->oid))
+       if (!oideq(&new_oid, &it->oid))
                BUG("cache-tree for path %.*s does not match. "
                    "Expected %s got %s", len, path->buf,
                    oid_to_hex(&new_oid), oid_to_hex(&it->oid));
index 00e5ceee6fc8c33dad6071862ee7fe7923f3aa33..a7808430e1a0a9187f4771eef0546924e00a3472 100644 (file)
@@ -426,7 +426,7 @@ struct contains_stack {
 static int in_commit_list(const struct commit_list *want, struct commit *c)
 {
        for (; want; want = want->next)
-               if (!oidcmp(&want->item->object.oid, &c->object.oid))
+               if (oideq(&want->item->object.oid, &c->object.oid))
                        return 1;
        return 0;
 }
diff --git a/midx.c b/midx.c
index f3e8dbc10820303436c07126b85d6024d2fb3e56..06aef564000d68441ac3966fd79ce535a3923b15 100644 (file)
--- a/midx.c
+++ b/midx.c
@@ -285,8 +285,8 @@ static int nth_midxed_pack_entry(struct multi_pack_index *m, struct pack_entry *
                struct object_id oid;
                nth_midxed_object_oid(&oid, m, pos);
                for (i = 0; i < p->num_bad_objects; i++)
-                       if (!hashcmp(oid.hash,
-                                    p->bad_object_sha1 + the_hash_algo->rawsz * i))
+                       if (hasheq(oid.hash,
+                                  p->bad_object_sha1 + the_hash_algo->rawsz * i))
                                return 0;
        }
 
@@ -583,8 +583,8 @@ static struct pack_midx_entry *get_sorted_entries(struct multi_pack_index *m,
                 * Take only the first duplicate.
                 */
                for (cur_object = 0; cur_object < nr_fanout; cur_object++) {
-                       if (cur_object && !oidcmp(&entries_by_fanout[cur_object - 1].oid,
-                                                 &entries_by_fanout[cur_object].oid))
+                       if (cur_object && oideq(&entries_by_fanout[cur_object - 1].oid,
+                                               &entries_by_fanout[cur_object].oid))
                                continue;
 
                        ALLOC_GROW(deduplicated_entries, *nr_objects + 1, alloc_objects);