]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pickaxe/style: consolidate declarations and assignments
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Mon, 12 Apr 2021 17:15:17 +0000 (19:15 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 May 2021 03:47:31 +0000 (12:47 +0900)
Refactor contains() to do its assignments at the same time that it
does its declarations.

This code could have been refactored in ef90ab66e8e (pickaxe: use
textconv for -S counting, 2012-10-28) when a function call between the
declarations and assignments was removed.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diffcore-pickaxe.c

index a9c6d60df22862e47ccb7fc1c7de9ed7cc4b1236..a278b9b71d9b58af197269cc6340050bba98acbe 100644 (file)
@@ -70,13 +70,9 @@ static int diff_grep(mmfile_t *one, mmfile_t *two,
 
 static unsigned int contains(mmfile_t *mf, regex_t *regexp, kwset_t kws)
 {
-       unsigned int cnt;
-       unsigned long sz;
-       const char *data;
-
-       sz = mf->size;
-       data = mf->ptr;
-       cnt = 0;
+       unsigned int cnt = 0;
+       unsigned long sz = mf->size;
+       const char *data = mf->ptr;
 
        if (regexp) {
                regmatch_t regmatch;