Skip to content

Commit 5819a51

Browse files
Seija KijinAZero13
authored andcommitted
Use ^=1 to toggle between 0 and 1
If it is known that an int is either 1 or 0, doing an exclusive or to switch instead of a modulus makes more sense and is more efficient. Signed-off-by: Seija <[email protected]>
1 parent 2ccc89b commit 5819a51

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@ static void mark_color_as_moved(struct diff_options *o,
12311231
&pmb_nr);
12321232

12331233
if (contiguous && pmb_nr && moved_symbol == l->s)
1234-
flipped_block = (flipped_block + 1) % 2;
1234+
flipped_block ^= 1;
12351235
else
12361236
flipped_block = 0;
12371237

t/helper/test-path-utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ static int check_dotfile(const char *x, const char **argv,
188188
int res = 0, expect = 1;
189189
for (; *argv; argv++) {
190190
if (!strcmp("--not", *argv))
191-
expect = !expect;
191+
expect ^= 1;
192192
else if (expect != (is_hfs(*argv) || is_ntfs(*argv)))
193193
res = error("'%s' is %s.git%s", *argv,
194194
expect ? "not " : "", x);

0 commit comments

Comments
 (0)