Invent the LST_FOREACH macro for looping through a list. In contrast
to the Lst_ForEach function this macro reduces the number of function calls per invocation by N + 1 (where N is the number of list elements) and increases code locality thereby increasing readability and (maybe) performance.
This commit is contained in:
parent
3a1757b9c0
commit
36120d91e5
@ -162,6 +162,10 @@ LstNode *Lst_Member(Lst *, void *);
|
||||
void Lst_ForEach(Lst *, DoProc *, void *);
|
||||
#define Lst_ForEach(LST, FN, D) (Lst_ForEachFrom((LST), Lst_First(LST), \
|
||||
(FN), (D)))
|
||||
|
||||
#define LST_FOREACH(PTR, LST) \
|
||||
for ((PTR) = (LST)->firstPtr; (PTR) != NULL; (PTR) = (PTR)->nextPtr)
|
||||
|
||||
/*
|
||||
* Apply a function to all elements of a lst starting from a certain point.
|
||||
* If the list is circular, the application will wrap around to the
|
||||
|
Loading…
Reference in New Issue
Block a user