summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2018-08-28 21:22:59 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-08-29 18:32:49 (GMT)
commit6a29d7b7a72c7b131ae3cda9e0b47b67a27a51f1 (patch)
tree6c1bb588fa181665d031b96f4b3a0488538bc6b2 /read-cache.c
parentcc00e5ce6b50cf4197e137b87a33209568b1e662 (diff)
downloadgit-6a29d7b7a72c7b131ae3cda9e0b47b67a27a51f1.zip
git-6a29d7b7a72c7b131ae3cda9e0b47b67a27a51f1.tar.gz
git-6a29d7b7a72c7b131ae3cda9e0b47b67a27a51f1.tar.bz2
read-cache: use oideq() in ce_compare functions
These functions return the full oidcmp() value, but the callers really only care whether it is non-zero. We can use the more strict !oideq(), which a compiler may be able to optimize further. This does change the meaning of the return value subtly, but it's unlikely that anybody would try to use them for ordering. They're static-local in this file, and they already return other error values that would confuse an ordering (e.g., open() failure gives -1). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/read-cache.c b/read-cache.c
index 421a7f4..eb7cea6 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -213,7 +213,7 @@ static int ce_compare_data(const struct cache_entry *ce, struct stat *st)
if (fd >= 0) {
struct object_id oid;
if (!index_fd(&oid, fd, st, OBJ_BLOB, ce->name, 0))
- match = oidcmp(&oid, &ce->oid);
+ match = !oideq(&oid, &ce->oid);
/* index_fd() closed the file descriptor already */
}
return match;
@@ -254,7 +254,7 @@ static int ce_compare_gitlink(const struct cache_entry *ce)
*/
if (resolve_gitlink_ref(ce->name, "HEAD", &oid) < 0)
return 0;
- return oidcmp(&oid, &ce->oid);
+ return !oideq(&oid, &ce->oid);
}
static int ce_modified_check_fs(const struct cache_entry *ce, struct stat *st)