Enlightenment CVS committal Author : rbdpngn Project : e17 Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore Modified Files: ecore_list.c Log Message: Fix the doubly linked list to use a more correct method to insert data in the list instead of walking from the beginning. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore/ecore_list.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -3 -r1.21 -r1.22 --- ecore_list.c 6 Jan 2006 17:58:12 -0000 1.21 +++ ecore_list.c 21 Feb 2006 05:45:18 -0000 1.22 @@ -472,7 +472,6 @@ /* Now move the current item to the inserted item */ list->current = new_node; - list->index++; list->nodes++; return TRUE; @@ -1176,32 +1175,35 @@ */ EAPI int ecore_dlist_insert(Ecore_DList * list, void *data) { - int ret; + int ret = TRUE; Ecore_DList_Node *prev; Ecore_DList_Node *node; CHECK_PARAM_POINTER_RETURN("list", list, FALSE); - prev = ECORE_DLIST_NODE(ECORE_LIST(list)->current); - if (!prev) - prev = ECORE_DLIST_NODE(ECORE_LIST(list)->last); - - if (prev) - prev = prev->previous; + /* + * Identify and shortcut the end cases. + */ + if (!ECORE_LIST(list)->current) + return ecore_dlist_append(list, data); + if (ECORE_LIST(list)->current == ECORE_LIST(list)->first) + return ecore_dlist_prepend(list, data); node = ecore_dlist_node_new(); ECORE_LIST_NODE(node)->data = data; - ret = _ecore_list_insert(list, ECORE_LIST_NODE(node)); - if (!ret) { - return ret; - } - - if (ECORE_LIST_NODE(node)->next) - ECORE_DLIST_NODE(ECORE_LIST_NODE(node)->next)->previous = node; + /* Setup the fields of the new node */ + ECORE_LIST_NODE(node)->next = ECORE_LIST(list)->current; - if (prev) - node->previous = prev; + /* And hook the node into the list */ + prev = ECORE_DLIST_NODE(ECORE_LIST(list)->current)->previous; + ECORE_LIST_NODE(prev)->next = ECORE_LIST_NODE(node); + ECORE_DLIST_NODE(ECORE_LIST(list)->current)->previous = node; + node->previous = prev; + + /* Now move the current item to the inserted item */ + ECORE_LIST(list)->current = ECORE_LIST_NODE(node); + ECORE_LIST(list)->nodes++; return ret; } ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs