aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Andree <matthias.andree@gmx.de>2010-04-24 05:09:18 +0200
committerMatthias Andree <matthias.andree@gmx.de>2010-04-24 06:16:47 +0200
commitd52b3f476e77703aefede89f6c25218ac5289bc3 (patch)
tree5738c996036e649a09bbc1d0565da068fe1cadc1
parent04c84b2fae19f5351247899fbce637deb9cec51d (diff)
downloadfetchmail-d52b3f476e77703aefede89f6c25218ac5289bc3.tar.gz
fetchmail-d52b3f476e77703aefede89f6c25218ac5289bc3.tar.bz2
fetchmail-d52b3f476e77703aefede89f6c25218ac5289bc3.zip
Make count_list iterative, to save function call overhead.
-rw-r--r--idlist.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/idlist.c b/idlist.c
index 8a7a7c79..d886de6b 100644
--- a/idlist.c
+++ b/idlist.c
@@ -156,11 +156,15 @@ void str_set_mark( struct idlist **idl, const char *str, const flag val)
/** Count the number of elements in the idlist \a idl.
* \return number of elements */
-int count_list( struct idlist **idl)
+int count_list(struct idlist **idl)
{
- if( !*idl )
- return 0;
- return 1 + count_list( &(*idl)->next );
+ int i = 0;
+ struct idlist *it;
+
+ for (it = *idl ; it ; it = it->next)
+ ++i;
+
+ return i;
}
/** return the \a number'th id string on idlist \a idl */