Thread (77 messages) 77 messages, 3 authors, 2021-04-12
STALE1919d
Revisions (2)
  1. v1 current
  2. v1 [diff vs current]

[PATCH 15/25] pickaxe/style: consolidate declarations and assignments

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-02-03 03:31:18
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
---
 diffcore-pickaxe.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
index 8df76afb6e..cb865c8b29 100644
--- a/diffcore-pickaxe.c
+++ b/diffcore-pickaxe.c
@@ -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;
-- 
2.30.0.284.gd98b1dd5eaa7
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help