summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-01-28 21:41:47 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-01-30 22:23:00 (GMT)
commit402bf8e19832142de97d84d37c51262d91e5f2db (patch)
tree6cf29f8b648cdd74c7fa58b2f159e603670ed46a /diff.c
parent35d803bc9a0d21c36b1381f6e42455beeb73b715 (diff)
downloadgit-402bf8e19832142de97d84d37c51262d91e5f2db.zip
git-402bf8e19832142de97d84d37c51262d91e5f2db.tar.gz
git-402bf8e19832142de97d84d37c51262d91e5f2db.tar.bz2
diff: use SWAP macro
Use the macro SWAP to exchange the value of pairs of variables instead of swapping them manually with the help of a temporary variable. The resulting code is shorter and easier to read. The two cases were not transformed by the semantic patch swap.cocci because it's extra careful and handles only cases where the types of all variables are the same -- and here we swap two ints and use an unsigned temporary variable for that. Nevertheless the conversion is safe, as the value range is preserved with and without the patch. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/diff.c b/diff.c
index 9de1ba2..6c4f3f6 100644
--- a/diff.c
+++ b/diff.c
@@ -5117,11 +5117,9 @@ void diff_change(struct diff_options *options,
return;
if (DIFF_OPT_TST(options, REVERSE_DIFF)) {
- unsigned tmp;
SWAP(old_mode, new_mode);
SWAP(old_sha1, new_sha1);
- tmp = old_sha1_valid; old_sha1_valid = new_sha1_valid;
- new_sha1_valid = tmp;
+ SWAP(old_sha1_valid, new_sha1_valid);
SWAP(old_dirty_submodule, new_dirty_submodule);
}