From b38f0e4f2635f76775602849f457d0012358730b Mon Sep 17 00:00:00 2001 From: Hannes Janetzek Date: Wed, 15 Jun 2011 20:52:26 +0000 Subject: [PATCH] e17/evry: only cleanup history when CLEANUP_THRESHOLD is reached. SVN revision: 60363 --- src/modules/everything/evry_history.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/modules/everything/evry_history.c b/src/modules/everything/evry_history.c index e4494a226..5e3e89a1c 100644 --- a/src/modules/everything/evry_history.c +++ b/src/modules/everything/evry_history.c @@ -4,6 +4,9 @@ #define SEVEN_DAYS 604800.0 +/* old history entries will be removed when threshold is reached */ +#define CLEANUP_THRESHOLD 500 + #define TIME_FACTOR(_now) (1.0 - (evry_hist->begin / _now)) / 1000000000000000.0 typedef struct _Cleanup_Data Cleanup_Data; @@ -164,23 +167,21 @@ _hist_cleanup_cb(const Eina_Hash *hash __UNUSED__, const void *key, void *data, void evry_history_free(void) { - Cleanup_Data *d; - evry_hist = e_config_domain_load("module.everything.cache", hist_edd); - if (evry_hist) + + if ((evry_hist) && (evry_hist->subjects) && + (eina_hash_population(evry_hist->subjects) > CLEANUP_THRESHOLD)) { + Cleanup_Data *d; + d = E_NEW(Cleanup_Data, 1); d->time = ecore_time_unix_get(); - - if (evry_hist->subjects) - { - eina_hash_foreach(evry_hist->subjects, _hist_cleanup_cb, d); - } - + eina_hash_foreach(evry_hist->subjects, _hist_cleanup_cb, d); E_FREE(d); - evry_history_unload(); } + evry_history_unload(); + E_CONFIG_DD_FREE(hist_item_edd); E_CONFIG_DD_FREE(hist_entry_edd); E_CONFIG_DD_FREE(hist_types_edd);