summaryrefslogtreecommitdiff
path: root/fast-import.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2018-08-28 21:22:40 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-08-29 18:32:49 (GMT)
commit4a7e27e95797c0a094f8ee300a260777ddd7eec9 (patch)
tree4c29cd40abed19f50f4fd2459429779d0c9b13d1 /fast-import.c
parent14438c4497c3ab3988cf50ebd504acef3735953c (diff)
downloadgit-4a7e27e95797c0a094f8ee300a260777ddd7eec9.zip
git-4a7e27e95797c0a094f8ee300a260777ddd7eec9.tar.gz
git-4a7e27e95797c0a094f8ee300a260777ddd7eec9.tar.bz2
convert "oidcmp() == 0" to oideq()
Using the more restrictive oideq() should, in the long run, give the compiler more opportunities to optimize these callsites. For now, this conversion should be a complete noop with respect to the generated code. The result is also perhaps a little more readable, as it avoids the "zero is equal" idiom. Since it's so prevalent in C, I think seasoned programmers tend not to even notice it anymore, but it can sometimes make for awkward double negations (e.g., we can drop a few !!oidcmp() instances here). This patch was generated almost entirely by the included coccinelle patch. This mechanical conversion should be completely safe, because we check explicitly for cases where oidcmp() is compared to 0, which is what oideq() is doing under the hood. Note that we don't have to catch "!oidcmp()" separately; coccinelle's standard isomorphisms make sure the two are treated equivalently. I say "almost" because I did hand-edit the coccinelle output to fix up a few style violations (it mostly keeps the original formatting, but sometimes unwraps long lines). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fast-import.c')
-rw-r--r--fast-import.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fast-import.c b/fast-import.c
index 89bb0c9..a731088 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -572,7 +572,7 @@ static struct object_entry *find_object(struct object_id *oid)
unsigned int h = oid->hash[0] << 8 | oid->hash[1];
struct object_entry *e;
for (e = object_table[h]; e; e = e->next)
- if (!oidcmp(oid, &e->idx.oid))
+ if (oideq(oid, &e->idx.oid))
return e;
return NULL;
}
@@ -583,7 +583,7 @@ static struct object_entry *insert_object(struct object_id *oid)
struct object_entry *e = object_table[h];
while (e) {
- if (!oidcmp(oid, &e->idx.oid))
+ if (oideq(oid, &e->idx.oid))
return e;
e = e->next;
}
@@ -1533,7 +1533,7 @@ static int tree_content_set(
if (!*slash1) {
if (!S_ISDIR(mode)
&& e->versions[1].mode == mode
- && !oidcmp(&e->versions[1].oid, oid))
+ && oideq(&e->versions[1].oid, oid))
return 0;
e->versions[1].mode = mode;
oidcpy(&e->versions[1].oid, oid);