diff options
author | Andrey Nazarov <skuller@skuller.net> | 2007-09-23 23:58:45 +0000 |
---|---|---|
committer | Andrey Nazarov <skuller@skuller.net> | 2007-09-23 23:58:45 +0000 |
commit | f41c5c89d12984e3269c4b4746050d5fe5e8caa1 (patch) | |
tree | 48391cf40e64820f66fd571a55433e4f1cb60700 /source/q_list.h | |
parent | f8da937c0e68f24f87f2e93c9c04bdf43afbfb05 (diff) |
Replaced link_t stuff with list_t handlers.
Server now tries to avoid cache misses when iterating
though client list by placing clients sequentally.
Diffstat (limited to 'source/q_list.h')
-rw-r--r-- | source/q_list.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/source/q_list.h b/source/q_list.h index a254cab..6a06af7 100644 --- a/source/q_list.h +++ b/source/q_list.h @@ -54,6 +54,21 @@ static inline void List_Insert( list_t *head, list_t *elem ) { List_Link( head, head->next, elem ); } +// add element to the list of elements allocated from the same memory pool +// used to mimimize cache misses when interating through the list +static inline void List_SeqAdd( list_t *list, list_t *elem ) { + list_t *cursor, *prev = NULL; + + for( cursor = list->next; cursor != list; cursor = cursor->next ) { + if( elem < cursor && elem > prev ) { + List_Link( cursor->prev, cursor, elem ); + return; + } + } + + List_Append( list, elem ); +} + static inline void List_Delete( list_t *elem ) { List_Unlink( elem->prev, elem->next ); List_Init( elem ); |