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 8fa4b09f. Signed-off-by: René Scharfe <rene.scharfe@lsrfire.ath.cx> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Jul 6, 2013 at 15:53 UTC
3bdb5b9f1fe964dc9ac4aa29b7b80b1e89ba84dc
1 file changed
+4
-7
diffcore-pickaxe.c
+4
-7
@@ -131,8 +131,7 @@ static void diffcore_pickaxe_grep(struct diff_options *o)
131
return;
132
}
133
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)
135
{
136
unsigned int cnt;
137
unsigned long sz;
@@ -176,11 +175,9 @@ static int has_changes(mmfile_t *one, mmfile_t *two,
175
struct diff_options *o,
176
regex_t *regexp, kwset_t kws)
177
{
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;
181
}
182
183
static int pickaxe_match(struct diff_filepair *p, struct diff_options *o,