Skip to content

Commit e4aab50

Browse files
rscharfegitster
authored andcommitted
pickaxe: simplify kwset loop in contains()
Inlining the variable "found" actually makes the code shorter and easier to read. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 542b2aa commit e4aab50

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

diffcore-pickaxe.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,10 @@ static unsigned int contains(mmfile_t *mf, regex_t *regexp, kwset_t kws)
9494
while (sz) {
9595
struct kwsmatch kwsm;
9696
size_t offset = kwsexec(kws, data, sz, &kwsm);
97-
const char *found;
9897
if (offset == -1)
9998
break;
100-
else
101-
found = data + offset;
102-
sz -= found - data + kwsm.size[0];
103-
data = found + kwsm.size[0];
99+
sz -= offset + kwsm.size[0];
100+
data += offset + kwsm.size[0];
104101
cnt++;
105102
}
106103
}

0 commit comments

Comments
 (0)