[RFC PATCH 4/5] config.c: refactor configset_iter()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use variables rather than long lines in configset_iter(), and use our
own "kvi" rather than relying on the global "current_config_kvi"
within this function.

There's no functional change here, but doing this will make a
subsequent functional change smaller.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
---
 config.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/config.c b/config.c
index a65e7bb36d3..230a98b0631 100644
--- a/config.c
+++ b/config.c
@@ -2227,17 +2227,22 @@ static void configset_iter(struct config_set *cs, config_fn_t fn, void *data)
 	struct configset_list *list = &cs->list;
 
 	for (i = 0; i < list->nr; i++) {
+		const char *key;
+		const char *val;
+		struct key_value_info *kvi;
+
 		entry = list->items[i].e;
 		value_index = list->items[i].value_index;
 		values = &entry->value_list;
 
-		current_config_kvi = values->items[value_index].util;
-
-		if (fn(entry->key, values->items[value_index].string, data) < 0)
-			git_die_config_linenr(entry->key,
-					      current_config_kvi->filename,
-					      current_config_kvi->linenr);
+		key = entry->key;
+		val = values->items[value_index].string;
+		kvi = values->items[value_index].util;
 
+		current_config_kvi = kvi;
+		if (fn(key, val, data) < 0)
+			git_die_config_linenr(entry->key, kvi->filename,
+					      kvi->linenr);
 		current_config_kvi = NULL;
 	}
 }
-- 
2.40.0.rc1.1034.g5867a1b10c5




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux