defer cache open

SVN revision: 55143
This commit is contained in:
Sebastian Dransfeld 2010-12-02 08:33:48 +00:00
parent 2ce2d03609
commit fec2ca310f
1 changed files with 24 additions and 10 deletions

View File

@ -51,6 +51,8 @@ static Efreet_Desktop *efreet_util_cache_find(const char *search, const char *wh
static Eina_List *efreet_util_cache_list(const char *search, const char *what);
static Eina_List *efreet_util_cache_glob_list(const char *search, const char *what);
static Eina_Bool cache_check(void);
static Eina_Hash *file_id_by_desktop_path = NULL;
static const char *cache_file = NULL;
static Eet_File *cache = NULL;
@ -69,8 +71,6 @@ efreet_util_init(void)
return 0;
}
/* TODO: Defer eet open until we actually need it open. */
cache = eet_open(efreet_desktop_util_cache_file(), EET_FILE_MODE_READ);
file_id_by_desktop_path = eina_hash_string_superfast_new(EINA_FREE_CB(eina_stringshare_del));
return init;
@ -238,7 +238,7 @@ efreet_util_desktop_exec_find(const char *exec)
int num, i;
Efreet_Desktop *ret = NULL;
if (!cache) return NULL;
if (!cache_check()) return NULL;
if (!exec) return NULL;
keys = eet_list(cache, "*::e", &num);
@ -331,7 +331,7 @@ efreet_util_desktop_exec_glob_list(const char *glob)
int num, i;
Eina_List *ret = NULL;
if (!cache) return NULL;
if (!cache_check()) return NULL;
if (!glob) return NULL;
keys = eet_list(cache, "*::e", &num);
@ -408,7 +408,7 @@ efreet_util_desktop_categories_list(void)
int num, i;
Eina_List *ret = NULL;
if (!cache) return NULL;
if (!cache_check()) return NULL;
keys = eet_list(cache, "*::ca", &num);
if (!keys) return NULL;
for (i = 0; i < num; i++)
@ -506,7 +506,7 @@ efreet_util_cache_find(const char *search, const char *what1, const char *what2)
int num, i;
Efreet_Desktop *ret = NULL;
if (!cache) return NULL;
if (!cache_check()) return NULL;
if ((!what1) && (!what2)) return NULL;
keys = eet_list(cache, search, &num);
@ -540,7 +540,7 @@ efreet_util_cache_list(const char *search, const char *what)
int num, i;
Eina_List *ret = NULL;
if (!cache) return NULL;
if (!cache_check()) return NULL;
if (!what) return NULL;
keys = eet_list(cache, search, &num);
@ -575,7 +575,7 @@ efreet_util_cache_glob_list(const char *search, const char *what)
int num, i;
Eina_List *ret = NULL;
if (!cache) return NULL;
if (!cache_check()) return NULL;
if (!what) return NULL;
keys = eet_list(cache, search, &num);
@ -606,6 +606,20 @@ efreet_util_cache_glob_list(const char *search, const char *what)
void
efreet_util_desktop_cache_reload(void)
{
if (cache) eet_close(cache);
cache = eet_open(efreet_desktop_util_cache_file(), EET_FILE_MODE_READ);
if (cache && cache != NON_EXISTING) eet_close(cache);
cache = NULL;
}
static Eina_Bool
cache_check(void)
{
if (cache == NON_EXISTING) return EINA_FALSE;
if (!cache)
cache = eet_open(efreet_desktop_util_cache_file(), EET_FILE_MODE_READ);
if (!cache)
{
cache = NON_EXISTING;
return EINA_FALSE;
}
return EINA_TRUE;
}