Ignore:
Timestamp:
Dec 22, 2008, 7:16:06 PM (13 years ago)
Author:
charles
Message:

(trunk libT) speed improvments from wereHamster

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/list.c

    r7467 r7469  
    159159}
    160160
     161
     162
     163/*
     164 * Double-linked list with easy memory management and fast
     165 * insert/remove operations
     166 */
     167
     168void
     169__tr_list_init( struct __tr_list * head )
     170{
     171    head->next = head;
     172    head->prev = head;
     173}
     174
     175void
     176__tr_list_insert( struct __tr_list * list,
     177                  struct __tr_list * prev,
     178                  struct __tr_list * next)
     179{
     180    next->prev = list;
     181    list->next = next;
     182    list->prev = prev;
     183    prev->next = list;
     184}
     185
     186void
     187__tr_list_splice( struct __tr_list * prev,
     188                  struct __tr_list * next)
     189{
     190    next->prev = prev;
     191    prev->next = next;
     192}
     193
     194 
     195void
     196__tr_list_append( struct __tr_list * head,
     197                  struct __tr_list * list)
     198{
     199    __tr_list_insert( list, head->prev, head );
     200}
     201
     202void
     203__tr_list_remove( struct __tr_list * head )
     204{
     205    __tr_list_splice( head->prev, head->next );
     206    head->next = head->prev = NULL;
     207}
     208
     209void
     210__tr_list_destroy( struct __tr_list * head,
     211                   __tr_list_free_t   func)
     212{
     213    while ( head->next != head )
     214    {
     215        struct __tr_list * list = head->next;
     216        __tr_list_splice( list->prev, list->next );
     217
     218        func( list );
     219    }
     220}
Note: See TracChangeset for help on using the changeset viewer.