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>
Jeff King committed
Aug 28, 2018 at 17:22 UTC
6a29d7b7a72c7b131ae3cda9e0b47b67a27a51f1
1 file changed
+2
-2
read-cache.c
+2
-2
@@ -213,7 +213,7 @@ static int ce_compare_data(const struct cache_entry *ce, struct stat *st)
213
if (fd >= 0) {
214
struct object_id oid;
215
if (!index_fd(&oid, fd, st, OBJ_BLOB, ce->name, 0))
216
- match = oidcmp(&oid, &ce->oid);
216
+ match = !oideq(&oid, &ce->oid);
217
/* index_fd() closed the file descriptor already */
218
}
219
return match;
@@ -254,7 +254,7 @@ static int ce_compare_gitlink(const struct cache_entry *ce)
254
*/
255
if (resolve_gitlink_ref(ce->name, "HEAD", &oid) < 0)
256
return 0;
257
- return oidcmp(&oid, &ce->oid);
257
+ return !oideq(&oid, &ce->oid);
258
}
259
260
static int ce_modified_check_fs(const struct cache_entry *ce, struct stat *st)