Skip to content

Commit dfcd923

Browse files
committed
config_file: remove unused list iteration macros
We currently provide a lot of macros for the `cvar_t` structure which are never being used. In fact, the only macro we need is to access the `next` pointer of `cvar_t`, which really does not require a macro at all. Remove all these macros and replace usage of `CVAR_LIST_NEXT(cvar)` with `cvar->next`.
1 parent 7bd129e commit dfcd923

File tree

1 file changed

+2
-40
lines changed

1 file changed

+2
-40
lines changed

src/config_file.c

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -38,44 +38,6 @@ typedef struct git_config_file_iter {
3838
/* Max depth for [include] directives */
3939
#define MAX_INCLUDE_DEPTH 10
4040

41-
#define CVAR_LIST_HEAD(list) ((list)->head)
42-
43-
#define CVAR_LIST_TAIL(list) ((list)->tail)
44-
45-
#define CVAR_LIST_NEXT(var) ((var)->next)
46-
47-
#define CVAR_LIST_EMPTY(list) ((list)->head == NULL)
48-
49-
#define CVAR_LIST_APPEND(list, var) do {\
50-
if (CVAR_LIST_EMPTY(list)) {\
51-
CVAR_LIST_HEAD(list) = CVAR_LIST_TAIL(list) = var;\
52-
} else {\
53-
CVAR_LIST_NEXT(CVAR_LIST_TAIL(list)) = var;\
54-
CVAR_LIST_TAIL(list) = var;\
55-
}\
56-
} while(0)
57-
58-
#define CVAR_LIST_REMOVE_HEAD(list) do {\
59-
CVAR_LIST_HEAD(list) = CVAR_LIST_NEXT(CVAR_LIST_HEAD(list));\
60-
} while(0)
61-
62-
#define CVAR_LIST_REMOVE_AFTER(var) do {\
63-
CVAR_LIST_NEXT(var) = CVAR_LIST_NEXT(CVAR_LIST_NEXT(var));\
64-
} while(0)
65-
66-
#define CVAR_LIST_FOREACH(list, iter)\
67-
for ((iter) = CVAR_LIST_HEAD(list);\
68-
(iter) != NULL;\
69-
(iter) = CVAR_LIST_NEXT(iter))
70-
71-
/*
72-
* Inspired by the FreeBSD functions
73-
*/
74-
#define CVAR_LIST_FOREACH_SAFE(start, iter, tmp)\
75-
for ((iter) = CVAR_LIST_HEAD(vars);\
76-
(iter) && (((tmp) = CVAR_LIST_NEXT(iter) || 1));\
77-
(iter) = (tmp))
78-
7941
typedef struct {
8042
git_atomic refcount;
8143
git_strmap *values;
@@ -188,7 +150,7 @@ static void free_vars(git_strmap *values)
188150

189151
git_strmap_foreach_value(values, var,
190152
while (var != NULL) {
191-
cvar_t *next = CVAR_LIST_NEXT(var);
153+
cvar_t *next = var->next;
192154
cvar_free(var);
193155
var = next;
194156
});
@@ -407,7 +369,7 @@ static int config_iterator_next(
407369
}
408370

409371
*entry = var->entry;
410-
it->next_var = CVAR_LIST_NEXT(var);
372+
it->next_var = var->next;
411373

412374
return 0;
413375
}

0 commit comments

Comments
 (0)