diff options
author | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2016-04-22 12:03:25 +0900 |
---|---|---|
committer | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2016-04-23 23:07:48 +0900 |
commit | e4d815dc48c660a336670ec3cc67e6becbdcacfc (patch) | |
tree | 7c9be7ba0a493b5fe40c6ea99167a0ecbe9a54f7 | |
parent | 0e9cf93c3069f68d906a8b706fa1169ad1fd2073 (diff) | |
download | efl-e4d815dc48c660a336670ec3cc67e6becbdcacfc.tar.gz |
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
-rw-r--r-- | src/bin/efreet/efreetd_cache.c | 12 | ||||
-rw-r--r-- | src/examples/elementary/codegen_example.edj | bin | 12063 -> 0 bytes | |||
-rw-r--r-- | src/lib/ecore_file/ecore_file_monitor_inotify.c | 13 | ||||
-rw-r--r-- | src/lib/ecore_file/ecore_file_monitor_poll.c | 13 | ||||
-rw-r--r-- | src/lib/ecore_file/ecore_file_monitor_win32.c | 20 | ||||
-rw-r--r-- | src/lib/ecore_file/ecore_file_private.h | 2 |
6 files changed, 29 insertions, 31 deletions
diff --git a/src/bin/efreet/efreetd_cache.c b/src/bin/efreet/efreetd_cache.c index fefc852dd0..9e8444fee4 100644 --- a/src/bin/efreet/efreetd_cache.c +++ b/src/bin/efreet/efreetd_cache.c @@ -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; diff --git a/src/examples/elementary/codegen_example.edj b/src/examples/elementary/codegen_example.edj Binary files differdeleted file mode 100644 index 4f87ec8c82..0000000000 --- a/src/examples/elementary/codegen_example.edj +++ /dev/null diff --git a/src/lib/ecore_file/ecore_file_monitor_inotify.c b/src/lib/ecore_file/ecore_file_monitor_inotify.c index f86b58d631..374d709265 100644 --- a/src/lib/ecore_file/ecore_file_monitor_inotify.c +++ b/src/lib/ecore_file/ecore_file_monitor_inotify.c @@ -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); } diff --git a/src/lib/ecore_file/ecore_file_monitor_poll.c b/src/lib/ecore_file/ecore_file_monitor_poll.c index 088787e3e9..16f84194ce 100644 --- a/src/lib/ecore_file/ecore_file_monitor_poll.c +++ b/src/lib/ecore_file/ecore_file_monitor_poll.c @@ -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) diff --git a/src/lib/ecore_file/ecore_file_monitor_win32.c b/src/lib/ecore_file/ecore_file_monitor_win32.c index f6186f6773..20f2ad02ad 100644 --- a/src/lib/ecore_file/ecore_file_monitor_win32.c +++ b/src/lib/ecore_file/ecore_file_monitor_win32.c @@ -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); } diff --git a/src/lib/ecore_file/ecore_file_private.h b/src/lib/ecore_file/ecore_file_private.h index 82f9767153..7c33ec8f34 100644 --- a/src/lib/ecore_file/ecore_file_private.h +++ b/src/lib/ecore_file/ecore_file_private.h @@ -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; }; |