]> arthur.barton.de Git - bup.git/commitdiff
_cmp_sha: Replace manual sha comparison with memcmp
authorRob Browning <rlb@defaultvalue.org>
Sun, 25 Feb 2018 18:03:21 +0000 (10:03 -0800)
committerRob Browning <rlb@defaultvalue.org>
Sun, 25 Mar 2018 19:22:10 +0000 (14:22 -0500)
...under the assumption that the platform-specific version may be more
efficient.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/_helpers.c

index f31fddb4c65e5e41604e390e35dd92f5cfa8e55a..87e8b82755d581762db9d9943fc822ed4cf5fb77 100644 (file)
@@ -742,6 +742,11 @@ struct sha {
     unsigned char bytes[20];
 };
 
+static inline int _cmp_sha(const struct sha *sha1, const struct sha *sha2)
+{
+    return memcmp(sha1->bytes, sha2->bytes, sizeof(sha1->bytes));
+}
+
 
 struct idx {
     unsigned char *map;
@@ -752,17 +757,6 @@ struct idx {
     int name_base;
 };
 
-
-static int _cmp_sha(const struct sha *sha1, const struct sha *sha2)
-{
-    int i;
-    for (i = 0; i < sizeof(struct sha); i++)
-       if (sha1->bytes[i] != sha2->bytes[i])
-           return sha1->bytes[i] - sha2->bytes[i];
-    return 0;
-}
-
-
 static void _fix_idx_order(struct idx **idxs, int *last_i)
 {
     struct idx *idx;