Menu

#26 simplify evl_list_t iteration

open
3
2003-12-18
2003-12-18
No

A random thought; didn't want to lose it over
Xmas...

The list functions defined in evl_list.c and evl_list.h
implement a doubly linked, circular list. It should be
NULL-terminated going forward (but still circular going
backward). That way, we could do

evl_listnode_t *p;
for (p=list; p; p=p->li_next) { ... }

instead of the current

evl_listnode_t *head=list, *p, *end;
for (p=head, end=NULL; p!=end; end=head, p=p->li_next)
{ ... }

or (in older code)

if (!head) { return; }
p = head;
do { ... p=p->li_next; } while (p != head);

We want to keep it circular going backward (i.e.,
head->li_prev points to the last node) to keep it
efficient to append. (So far, no code interates
backward through a list.)

This change would affect over 80 loops in about 20
source files.

Jim Keniston 12/18/03

Discussion


Log in to post a comment.