Enlightenment CVS committal
Author : onefang
Project : e17
Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore_desktop
Modified Files:
Ecore_Desktop.h ecore_desktop_icon.c
Log Message:
Hash the icon directories for speed.
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_desktop/Ecore_Desktop.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -3 -r1.40 -r1.41
--- Ecore_Desktop.h 14 Oct 2006 04:14:28 -0000 1.40
+++ Ecore_Desktop.h 15 Oct 2006 19:09:07 -0000 1.41
@@ -91,7 +91,8 @@
struct _Ecore_Desktop_Icon_Theme_Directory
{
- char *path;
+ Ecore_Hash *icons;
+ char *full_path;
char *type;
int size, minimum, maximum, threshold;
};
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_desktop/ecore_desktop_icon.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -3 -r1.40 -r1.41
--- ecore_desktop_icon.c 13 Oct 2006 23:25:43 -0000 1.40
+++ ecore_desktop_icon.c 15 Oct 2006 19:09:07 -0000 1.41
@@ -10,7 +10,8 @@
static char *_ecore_desktop_icon_find0(const char *icon,
const char *icon_size,
- const char *icon_theme);
+ const char *icon_theme,
+ int *in_cache);
static int _ecore_desktop_icon_theme_list_add(void *data,
const char *path);
@@ -86,7 +87,7 @@
if ((ext) && (!strcmp(ext, ".ico")))
continue;
- result = _ecore_desktop_icon_find0(icn, icon_size,
icon_theme);
+ result = _ecore_desktop_icon_find0(icn, icon_size,
icon_theme, &in_cache);
if (result)
break;
}
@@ -129,7 +130,7 @@
*/
static char *
_ecore_desktop_icon_find0(const char *icon, const char *icon_size,
- const char *icon_theme)
+ const char *icon_theme, int *in_cache)
{
/* NOTES ON OPTIMIZATIONS
*
@@ -153,7 +154,7 @@
* the directory where the index.theme file lives.
*
* On the other hand, OS caching (at least in linux) seems to do a
reasonable
- * job here.
+ * job here. But not good enough though.
*
* We also precalculate and cache all the information extracted from
* the .theme files.
@@ -250,11 +251,29 @@
continue;
if ((ext[i][0] != '\0') && (has_icon_ext))
continue;
- snprintf(path, PATH_MAX, "%s/%s/%s%s", icon_theme,
directory->path, icon, ext[i]);
+ if (directory->icons)
+ {
+ snprintf(path, PATH_MAX, "%s%s", icon, ext[i]);
#ifdef DEBUG
- printf("FDO icon = %s\n", path);
+ printf("FDO icon = %s\n", path);
#endif
- found =
ecore_desktop_paths_file_find(ecore_desktop_paths_icons, path, 0, NULL, NULL);
+ found = ecore_hash_get(directory->icons, path);
+ if (found)
+ {
+ found = strdup(found);
+ if (match)
+ *in_cache = 1;
+ }
+ }
+ else
+ {
+ snprintf(path, PATH_MAX, "%s/%s%s",
directory->full_path, icon, ext[i]);
+#ifdef DEBUG
+ printf("FDO icon = %s\n", path);
+#endif
+ if (ecore_file_exists(path))
+ found = strdup(path);
+ }
if (found)
{
if (ecore_file_is_dir(found))
@@ -302,13 +321,13 @@
ecore_list_goto_first(theme->Inherits);
while ((inherits = ecore_list_next(theme->Inherits)) != NULL)
{
- found = _ecore_desktop_icon_find0(icon, icon_size,
inherits);
+ found = _ecore_desktop_icon_find0(icon, icon_size,
inherits, in_cache);
if (found) goto done;
}
}
else /* Fall back strategy #3, Try the default hicolor theme. */
{
- found = _ecore_desktop_icon_find0(icon, icon_size, "hicolor");
+ found = _ecore_desktop_icon_find0(icon, icon_size, "hicolor",
in_cache);
if (found) goto done;
}
}
@@ -443,7 +462,7 @@
ecore_desktop_icon_theme_get(const char *icon_theme, const char *lang)
{
Ecore_Desktop_Icon_Theme *result = NULL;
- char *theme_path = NULL, *dir = NULL;
+ char *theme_path = NULL, *theme_dir = NULL;
char *value;
Ecore_List *Directories;
char *directory;
@@ -451,17 +470,17 @@
if (icon_theme[0] == '/')
{
theme_path = strdup(icon_theme);
- dir = ecore_file_get_dir(theme_path);
- if (dir)
- icon_theme = (char *)ecore_file_get_file(dir);
-#ifdef DEBUG
+ theme_dir = ecore_file_get_dir(theme_path);
+ if (theme_dir)
+ icon_theme = (char *)ecore_file_get_file(theme_dir);
+//#ifdef DEBUG
printf("LOADING THEME %s - %s\n", icon_theme, theme_path);
-#endif
+//#endif
}
result = ecore_hash_get(icon_theme_cache, icon_theme);
if (result) goto done;
- if (!dir)
+ if (!theme_dir)
{
char icn[PATH_MAX];
@@ -471,6 +490,7 @@
#endif
theme_path = ecore_desktop_paths_file_find(ecore_desktop_paths_icons,
icn,
2, NULL, NULL);
+ theme_dir = ecore_file_get_dir(theme_path);
}
if (!theme_path) goto error;
result = calloc(1, sizeof(Ecore_Desktop_Icon_Theme));
@@ -480,6 +500,7 @@
result->group = ecore_hash_get(result->data, "Icon Theme");
if (!result->group) goto error;
+
if ((strcmp(icon_theme, "hicolor") == 0))
result->hicolor = 1;
@@ -522,8 +543,10 @@
if ((dir) && (sub_group))
{
char *size, *minsize, *maxsize, *threshold;
+ char full_path[PATH_MAX];
- dir->path = strdup(directory);
+ snprintf(full_path, PATH_MAX, "%s/%s", theme_dir, directory);
+ dir->full_path = strdup(full_path);
value = ecore_hash_get(sub_group, "Type");
if (!value)
value = "Threshold";
@@ -546,6 +569,27 @@
dir->size = atoi(size);
ecore_list_append(result->Directories, dir);
+
+ dir->icons = ecore_hash_new(ecore_str_hash,
ecore_str_compare);
+ if (dir->icons)
+ {
+ Ecore_List *files;
+
+ ecore_hash_set_free_key(dir->icons, free);
+ ecore_hash_set_free_value(dir->icons, free);
+ files = ecore_file_ls(dir->full_path);
+ if (files)
+ {
+ const char *file;
+
+ while ((file = ecore_list_next(files)))
+ {
+ snprintf(full_path, PATH_MAX, "%s/%s",
dir->full_path, file);
+ ecore_hash_set(dir->icons, strdup(file),
strdup(full_path));
+ }
+ ecore_list_destroy(files);
+ }
+ }
}
else
_ecore_desktop_icon_theme_directory_destroy(dir);
@@ -563,13 +607,13 @@
result->group = NULL;
done:
- if (dir) free(dir);
+ if (theme_dir) free(theme_dir);
if (theme_path) free(theme_path);
return result;
error:
- if (dir) free(dir);
+ if (theme_dir) free(theme_dir);
if (theme_path) free(theme_path);
if (result)
{
@@ -621,9 +665,11 @@
_ecore_desktop_icon_theme_directory_destroy(Ecore_Desktop_Icon_Theme_Directory
*
icon_theme_directory)
{
- if (icon_theme_directory->path)
- free(icon_theme_directory->path);
+ if (icon_theme_directory->full_path)
+ free(icon_theme_directory->full_path);
if (icon_theme_directory->type)
free(icon_theme_directory->type);
+ if (icon_theme_directory->icons)
+ ecore_hash_destroy(icon_theme_directory->icons);
free(icon_theme_directory);
}
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs