Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        e16-ecore_list.c 


Log Message:
Speed up list iterators.

===================================================================
RCS file: /cvs/e/e16/e/src/e16-ecore_list.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- e16-ecore_list.c    25 Jul 2007 20:02:57 -0000      1.10
+++ e16-ecore_list.c    22 Mar 2008 16:45:06 -0000      1.11
@@ -720,7 +720,7 @@
 static void        *
 _ecore_list_first_goto(Ecore_List * list)
 {
-   if (!list || !list->first)
+   if (!list->first)
       return NULL;
 
    list->current = list->first;
@@ -871,14 +871,16 @@
 _ecore_list_for_each(Ecore_List * list, Ecore_For_Each function,
                     void *user_data)
 {
-   void               *value;
+   Ecore_List_Node    *node, *next;
 
-   if (!list || !function)
+   if (!function)
       return FALSE;
 
-   _ecore_list_first_goto(list);
-   while ((value = _ecore_list_next(list)) != NULL)
-      function(value, user_data);
+   for (node = list->first; node; node = next)
+     {
+       next = node->next;
+       function(node->data, user_data);
+     }
 
    return TRUE;
 }
@@ -904,15 +906,17 @@
 _ecore_list_find(Ecore_List * list, Ecore_Compare_Cb function,
                 const void *user_data)
 {
-   void               *value;
+   Ecore_List_Node    *node, *next;
 
-   if (!list || !function)
+   if (!function)
       return NULL;
 
-   _ecore_list_first_goto(list);
-   while ((value = _ecore_list_next(list)) != NULL)
-      if (!function(value, user_data))
-        return value;
+   for (node = list->first; node; node = next)
+     {
+       next = node->next;
+       if (!function(node->data, user_data))
+          return node->data;
+     }
 
    return NULL;
 }



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to