From 826e42997cbdfb927aa7929a65a6b8a0fe8a6adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Lach?= Date: Fri, 26 Mar 2021 09:59:33 +0100 Subject: [PATCH] - Coding style fix for common/counters.c - Change lookup for counter by id to use id as offset in array --- common/counters.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/common/counters.c b/common/counters.c index d3bf54e413..ec7a9ae4bb 100644 --- a/common/counters.c +++ b/common/counters.c @@ -64,15 +64,7 @@ struct counter *counter_by_id(int id) fc_assert_ret_val(id < MAX_COUNTERS, NULL); - for (i = 0; i < MAX_COUNTERS; i++) { - - if (counters[i].id == id) { - - return &counters[i]; - } - } - - return NULL; + return &counters[id]; } /************************************************************************//** @@ -95,9 +87,7 @@ struct counter *counter_by_rule_name(const char *name) fc_assert_ret_val('\0' != name[0], NULL); for (i = 0; i < MAX_COUNTERS; i++) { - if (0 == fc_strcasecmp(name, counters[i].rule_name)) { - return &counters[i]; } } @@ -129,9 +119,7 @@ int counter_index(struct counter *pcount) struct counter *counter_by_index(int index, enum counter_target target) { switch (target) { - case CTGT_CITY: - return counters_city[index]; break; -- 2.30.2