Exchanging the value of two variables requires declaring a temporary
variable and repeating their names. The swap macro in apply.c
simplifies this for its callers without changing the compiled binary.
Polish this macro and export it, then use it throughout the code to
reduce repetition and hide the declaration of temporary variables.
add SWAP macro
apply: use SWAP macro
use SWAP macro
diff: use SWAP macro
graph: use SWAP macro
apply.c | 23 +++
builtin/diff-tree.c | 4 +---
builtin/diff.c| 9 +++--
contrib/coccinelle/swap.cocci | 28
diff-no-index.c | 6 ++
diff.c| 12
git-compat-util.h | 10 ++
graph.c | 11 ++-
line-range.c | 3 +--
merge-recursive.c | 5 +
object.c | 4 +---
pack-revindex.c | 5 +
prio-queue.c | 4 +---
strbuf.h | 4 +---
14 files changed, 63 insertions(+), 65 deletions(-)
create mode 100644 contrib/coccinelle/swap.cocci
--
2.11.0