convert "oidcmp() == 0" to oideq()
authorJeff King <peff@peff.net>
Tue, 28 Aug 2018 21:22:40 +0000 (17:22 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 29 Aug 2018 18:32:49 +0000 (11:32 -0700)
commit4a7e27e95797c0a094f8ee300a260777ddd7eec9
tree4c29cd40abed19f50f4fd2459429779d0c9b13d1
parent14438c4497c3ab3988cf50ebd504acef3735953c
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>
52 files changed:
bisect.c
blame.c
builtin/am.c
builtin/checkout.c
builtin/describe.c
builtin/diff.c
builtin/difftool.c
builtin/fast-export.c
builtin/fetch.c
builtin/fmt-merge-msg.c
builtin/index-pack.c
builtin/log.c
builtin/merge-tree.c
builtin/merge.c
builtin/pack-objects.c
builtin/pull.c
builtin/receive-pack.c
builtin/remote.c
builtin/replace.c
builtin/unpack-objects.c
builtin/update-index.c
bulk-checkin.c
cache-tree.c
cache.h
combine-diff.c
commit-graph.c
connect.c
contrib/coccinelle/object_id.cocci
diff-lib.c
diff.c
diffcore-break.c
fast-import.c
http-push.c
log-tree.c
merge-recursive.c
notes-merge.c
notes.c
pack-write.c
read-cache.c
ref-filter.c
refs/files-backend.c
remote.c
revision.c
sequencer.c
sha1-array.c
sha1-file.c
sha1-name.c
submodule.c
transport.c
unpack-trees.c
wt-status.c
xdiff-interface.c