forked from enlightenment/efl
efreetd - reduce memory usage by using stringshare much more
lots of long paths for monitoring file paths for icons etc. are in memory for efreetd. this reduces that memory by sharing them much more. @optimization
This commit is contained in:
parent
0e9cf93c30
commit
e4d815dc48
|
@ -89,7 +89,7 @@ subdir_cache_dir_free(Subdir_Cache_Dir *cd)
|
|||
static void *
|
||||
subdir_cache_hash_add(void *hash, const char *key, void *data)
|
||||
{
|
||||
if (!hash) hash = eina_hash_string_superfast_new(EINA_FREE_CB(subdir_cache_dir_free));
|
||||
if (!hash) hash = eina_hash_stringshared_new(EINA_FREE_CB(subdir_cache_dir_free));
|
||||
if (!hash) return NULL;
|
||||
eina_hash_add(hash, key, data);
|
||||
return hash;
|
||||
|
@ -140,7 +140,7 @@ subdir_cache_init(void)
|
|||
|
||||
// if we don't have a hash in the subdir cache - allocate it
|
||||
if (!subdir_cache->dirs)
|
||||
subdir_cache->dirs = eina_hash_string_superfast_new(EINA_FREE_CB(subdir_cache_dir_free));
|
||||
subdir_cache->dirs = eina_hash_stringshared_new(EINA_FREE_CB(subdir_cache_dir_free));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -303,7 +303,7 @@ icon_cache_update_cache_cb(void *data EINA_UNUSED)
|
|||
if ((!icon_flush) && (!icon_exts)) return ECORE_CALLBACK_CANCEL;
|
||||
|
||||
if (icon_change_monitors) eina_hash_free(icon_change_monitors);
|
||||
icon_change_monitors = eina_hash_string_superfast_new
|
||||
icon_change_monitors = eina_hash_stringshared_new
|
||||
(EINA_FREE_CB(ecore_file_monitor_del));
|
||||
icon_changes_listen();
|
||||
subdir_cache_save();
|
||||
|
@ -360,7 +360,7 @@ desktop_cache_update_cache_cb(void *data EINA_UNUSED)
|
|||
desktop_queue = EINA_FALSE;
|
||||
|
||||
if (desktop_change_monitors) eina_hash_free(desktop_change_monitors);
|
||||
desktop_change_monitors = eina_hash_string_superfast_new
|
||||
desktop_change_monitors = eina_hash_stringshared_new
|
||||
(EINA_FREE_CB(ecore_file_monitor_del));
|
||||
desktop_changes_listen();
|
||||
subdir_cache_save();
|
||||
|
@ -867,9 +867,9 @@ cache_init(void)
|
|||
goto error;
|
||||
}
|
||||
|
||||
icon_change_monitors = eina_hash_string_superfast_new
|
||||
icon_change_monitors = eina_hash_stringshared_new
|
||||
(EINA_FREE_CB(ecore_file_monitor_del));
|
||||
desktop_change_monitors = eina_hash_string_superfast_new
|
||||
desktop_change_monitors = eina_hash_stringshared_new
|
||||
(EINA_FREE_CB(ecore_file_monitor_del));
|
||||
|
||||
efreet_cache_update = 0;
|
||||
|
|
Binary file not shown.
|
@ -107,7 +107,8 @@ ecore_file_monitor_backend_add(const char *path,
|
|||
void *data)
|
||||
{
|
||||
Ecore_File_Monitor *em;
|
||||
int len;
|
||||
char *path2;
|
||||
size_t len;
|
||||
|
||||
if (_inotify_fd_pid == -1) return NULL;
|
||||
|
||||
|
@ -123,10 +124,10 @@ ecore_file_monitor_backend_add(const char *path,
|
|||
em->func = func;
|
||||
em->data = data;
|
||||
|
||||
em->path = strdup(path);
|
||||
len = strlen(em->path);
|
||||
if (em->path[len - 1] == '/' && strcmp(em->path, "/"))
|
||||
em->path[len - 1] = 0;
|
||||
len = strlen(path);
|
||||
path2 = alloca(len + 1);
|
||||
if (path2[len - 1] == '/' && strcmp(path2, "/")) path2[len - 1] = 0;
|
||||
em->path = eina_stringshare_add(path2);
|
||||
|
||||
_monitors = ECORE_FILE_MONITOR(eina_inlist_append(EINA_INLIST_GET(_monitors), EINA_INLIST_GET(em)));
|
||||
|
||||
|
@ -149,7 +150,7 @@ ecore_file_monitor_backend_del(Ecore_File_Monitor *em)
|
|||
fd = ecore_main_fd_handler_fd_get(_fdh);
|
||||
if (ECORE_FILE_MONITOR_INOTIFY(em)->wd)
|
||||
inotify_rm_watch(fd, ECORE_FILE_MONITOR_INOTIFY(em)->wd);
|
||||
free(em->path);
|
||||
eina_stringshare_del(em->path);
|
||||
free(em);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ ecore_file_monitor_backend_add(const char *path,
|
|||
void *data)
|
||||
{
|
||||
Ecore_File_Monitor *em;
|
||||
char *path2;
|
||||
size_t len;
|
||||
|
||||
if (!path) return NULL;
|
||||
|
@ -81,14 +82,14 @@ ecore_file_monitor_backend_add(const char *path,
|
|||
else
|
||||
ecore_timer_interval_set(_timer, ECORE_FILE_INTERVAL_MIN);
|
||||
|
||||
em->path = strdup(path);
|
||||
len = strlen(em->path);
|
||||
if (em->path[len - 1] == '/' && strcmp(em->path, "/"))
|
||||
em->path[len - 1] = 0;
|
||||
|
||||
em->func = func;
|
||||
em->data = data;
|
||||
|
||||
len = strlen(path);
|
||||
path2 = alloca(len + 1);
|
||||
if (path2[len - 1] == '/' && strcmp(path2, "/")) path2[len - 1] = 0;
|
||||
em->path = eina_stringshare_add(path2);
|
||||
|
||||
ECORE_FILE_MONITOR_POLL(em)->mtime = ecore_file_mod_time(em->path);
|
||||
_monitors = ECORE_FILE_MONITOR(eina_inlist_append(EINA_INLIST_GET(_monitors), EINA_INLIST_GET(em)));
|
||||
|
||||
|
@ -160,7 +161,7 @@ ecore_file_monitor_backend_del(Ecore_File_Monitor *em)
|
|||
if (_monitors)
|
||||
_monitors = ECORE_FILE_MONITOR(eina_inlist_remove(EINA_INLIST_GET(_monitors), EINA_INLIST_GET(em)));
|
||||
|
||||
free(em->path);
|
||||
eina_stringshare_del(em->path);
|
||||
free(em);
|
||||
|
||||
if (_timer)
|
||||
|
|
|
@ -243,6 +243,7 @@ ecore_file_monitor_backend_add(const char *path,
|
|||
{
|
||||
Ecore_File_Monitor_Win32 *m;
|
||||
Ecore_File_Monitor *em;
|
||||
char *path2;
|
||||
size_t len;
|
||||
|
||||
if (!path || (*path == '\0')) return NULL;
|
||||
|
@ -256,22 +257,17 @@ ecore_file_monitor_backend_add(const char *path,
|
|||
em->func = func;
|
||||
em->data = data;
|
||||
|
||||
em->path = strdup(path);
|
||||
if (!em->path)
|
||||
{
|
||||
free(em);
|
||||
return NULL;
|
||||
}
|
||||
len = strlen(em->path);
|
||||
if (em->path[len - 1] == '/' || em->path[len - 1] == '\\')
|
||||
em->path[len - 1] = '\0';
|
||||
len = strlen(path);
|
||||
path2 = alloca(len + 1);
|
||||
if (path2[len - 1] == '/' || path2[len - 1] == '\\') path2[len - 1] = 0;
|
||||
em->path = eina_stringshare_add(path2);
|
||||
|
||||
m = ECORE_FILE_MONITOR_WIN32(em);
|
||||
|
||||
m->file = _ecore_file_monitor_win32_data_new(em, 0);
|
||||
if (!m->file)
|
||||
{
|
||||
free(em->path);
|
||||
eina_stringshare_del(em->path);
|
||||
free(em);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -280,7 +276,7 @@ ecore_file_monitor_backend_add(const char *path,
|
|||
if (!m->dir)
|
||||
{
|
||||
_ecore_file_monitor_win32_data_free(m->file);
|
||||
free(em->path);
|
||||
eina_stringshare_del(em->path);
|
||||
free(em);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -301,6 +297,6 @@ ecore_file_monitor_backend_del(Ecore_File_Monitor *em)
|
|||
m = ECORE_FILE_MONITOR_WIN32(em);
|
||||
_ecore_file_monitor_win32_data_free(m->dir);
|
||||
_ecore_file_monitor_win32_data_free(m->file);
|
||||
free(em->path);
|
||||
eina_stringshare_del(em->path);
|
||||
free(em);
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ struct _Ecore_File_Monitor
|
|||
Ecore_File_Event event,
|
||||
const char *path);
|
||||
|
||||
char *path;
|
||||
const char *path;
|
||||
void *data;
|
||||
Ecore_File *files;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue