Enlightenment CVS committal

Author  : englebass
Project : e17
Module  : libs/efreet

Dir     : e17/libs/efreet/src/lib


Modified Files:
        efreet_utils.c 


Log Message:
Use ecore_hash_find, no need to loop through the whole hash.

===================================================================
RCS file: /cvs/e/e17/libs/efreet/src/lib/efreet_utils.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- efreet_utils.c      25 Mar 2007 16:17:19 -0000      1.12
+++ efreet_utils.c      25 Mar 2007 16:44:47 -0000      1.13
@@ -21,16 +21,15 @@
 
 struct _Efreet_Cache_Search
 {
-    Efreet_Desktop *desktop;
     const char     *what1;
     const char     *what2;
 };
 
 static int  _efreet_util_cache_fill(void *data);
 static void _efreet_util_cache_dir_free(void *data);
-static void _efreet_util_cache_search_wm_class(void *value, void *data);
-static void _efreet_util_cache_search_name(void *value, void *data);
-static void _efreet_util_cache_search_generic_name(void *value, void *data);
+static int  _efreet_util_cache_search_wm_class(const void *value, const void 
*data);
+static int  _efreet_util_cache_search_name(const void *value, const void 
*data);
+static int  _efreet_util_cache_search_generic_name(const void *value, const 
void *data);
 
 static Ecore_Hash *desktop_by_file_id = NULL;
 static Ecore_Hash *desktop_by_exec = NULL;
@@ -167,11 +166,9 @@
     Efreet_Cache_Search search;
 
     if ((!wmname) && (!wmclass)) return NULL;
-    search.desktop = NULL;
     search.what1 = wmname;
     search.what2 = wmclass;
-    ecore_hash_for_each_node(desktop_by_exec, 
_efreet_util_cache_search_wm_class, &search);
-    return search.desktop;
+    return ecore_hash_find(desktop_by_exec, 
_efreet_util_cache_search_wm_class, &search);
 }
 
 Efreet_Desktop *
@@ -238,11 +235,9 @@
     Efreet_Cache_Search search;
 
     if (!name) return NULL;
-    search.desktop = NULL;
     search.what1 = name;
     search.what2 = NULL;
-    ecore_hash_for_each_node(desktop_by_exec, _efreet_util_cache_search_name, 
&search);
-    return search.desktop;
+    return ecore_hash_find(desktop_by_exec, _efreet_util_cache_search_name, 
&search);
 }
 
 Efreet_Desktop *
@@ -251,11 +246,9 @@
     Efreet_Cache_Search search;
 
     if (!generic_name) return NULL;
-    search.desktop = NULL;
     search.what1 = generic_name;
     search.what2 = NULL;
-    ecore_hash_for_each_node(desktop_by_exec, 
_efreet_util_cache_search_generic_name, &search);
-    return search.desktop;
+    return ecore_hash_find(desktop_by_exec, 
_efreet_util_cache_search_generic_name, &search);
 }
 
 #if 0
@@ -381,50 +374,45 @@
     free(dir);
 }
 
-static void
-_efreet_util_cache_search_wm_class(void *value, void *data)
+static int
+_efreet_util_cache_search_wm_class(const void *value, const void *data)
 {
-    Ecore_Hash_Node     *node;
-    Efreet_Cache_Search *search;
-    Efreet_Desktop      *desktop;
+    const Efreet_Cache_Search *search;
+    const Efreet_Desktop      *desktop;
 
-    node = value;
+    desktop = value;
     search = data;
 
-    desktop = node->value;
-    if (!desktop->startup_wm_class) return;
+    if (!desktop->startup_wm_class) return 1;
     if ((search->what1) && (!strcmp(desktop->startup_wm_class, search->what1)))
-        search->desktop = desktop;
+        return 0;
     else if ((search->what2) && (!strcmp(desktop->startup_wm_class, 
search->what2)))
-        search->desktop = desktop;
+        return 0;
+    return 1;
 }
 
-static void
-_efreet_util_cache_search_name(void *value, void *data)
+static int
+_efreet_util_cache_search_name(const void *value, const void *data)
 {
-    Ecore_Hash_Node     *node;
-    Efreet_Cache_Search *search;
-    Efreet_Desktop      *desktop;
+    const Efreet_Cache_Search *search;
+    const Efreet_Desktop      *desktop;
 
-    node = value;
+    desktop = value;
     search = data;
 
-    desktop = node->value;
-    if (!desktop->name) return;
-    if (!strcmp(desktop->name, search->what1)) search->desktop = desktop;
+    if (!desktop->name) return 1;
+    return (!strcmp(desktop->name, search->what1));
 }
 
-static void
-_efreet_util_cache_search_generic_name(void *value, void *data)
+static int
+_efreet_util_cache_search_generic_name(const void *value, const void *data)
 {
-    Ecore_Hash_Node     *node;
-    Efreet_Cache_Search *search;
-    Efreet_Desktop      *desktop;
+    const Efreet_Cache_Search *search;
+    const Efreet_Desktop      *desktop;
 
-    node = value;
+    desktop = value;
     search = data;
 
-    desktop = node->value;
-    if (!desktop->generic_name) return;
-    if (!strcmp(desktop->generic_name, search->what1)) search->desktop = 
desktop;
+    if (!desktop->generic_name) return 0;
+    return (!strcmp(desktop->generic_name, search->what1));
 }



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to