summaryrefslogtreecommitdiffstats
path: root/usr.bin/make
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2005-02-22 07:58:53 +0000
committerharti <harti@FreeBSD.org>2005-02-22 07:58:53 +0000
commitefff8cf1812e201288e8ae6d4648a80b7120f42f (patch)
tree03d3357420584b139f3eb62d2683dd39cfbf003e /usr.bin/make
parent38f30cf325c63613bb561ad3833e16b1d3298921 (diff)
downloadFreeBSD-src-efff8cf1812e201288e8ae6d4648a80b7120f42f.zip
FreeBSD-src-efff8cf1812e201288e8ae6d4648a80b7120f42f.tar.gz
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.
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/lst.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/usr.bin/make/lst.h b/usr.bin/make/lst.h
index 3ec17f1..76535cc 100644
--- a/usr.bin/make/lst.h
+++ b/usr.bin/make/lst.h
@@ -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
OpenPOWER on IntegriCloud