Skip to content

Commit 3bdb5b9

Browse files
René Scharfegitster
authored andcommitted
diffcore-pickaxe: simplify has_changes and contains
Halve the number of callsites of contains() to two using temporary variables, simplifying the code. While at it, get rid of the diff_options parameter, which became unused with 8fa4b09. Signed-off-by: René Scharfe <[email protected]> Acked-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 61690bf commit 3bdb5b9

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

diffcore-pickaxe.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ static void diffcore_pickaxe_grep(struct diff_options *o)
131131
return;
132132
}
133133

134-
static unsigned int contains(mmfile_t *mf, struct diff_options *o,
135-
regex_t *regexp, kwset_t kws)
134+
static unsigned int contains(mmfile_t *mf, regex_t *regexp, kwset_t kws)
136135
{
137136
unsigned int cnt;
138137
unsigned long sz;
@@ -176,11 +175,9 @@ static int has_changes(mmfile_t *one, mmfile_t *two,
176175
struct diff_options *o,
177176
regex_t *regexp, kwset_t kws)
178177
{
179-
if (!one)
180-
return contains(two, o, regexp, kws) != 0;
181-
if (!two)
182-
return contains(one, o, regexp, kws) != 0;
183-
return contains(one, o, regexp, kws) != contains(two, o, regexp, kws);
178+
unsigned int one_contains = one ? contains(one, regexp, kws) : 0;
179+
unsigned int two_contains = two ? contains(two, regexp, kws) : 0;
180+
return one_contains != two_contains;
184181
}
185182

186183
static int pickaxe_match(struct diff_filepair *p, struct diff_options *o,

0 commit comments

Comments
 (0)