From 921304555c9f0b1b6654fbbb68b1f9d8f26a3a81 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Sat, 3 Mar 2007 09:04:47 +0000 Subject: [PATCH] now limit stats per any 1 file to STAT_GAP (2 seconds). SVN revision: 28544 --- .../src/lib/engines/common/evas_image_load.c | 4 +- .../src/lib/engines/common/evas_image_main.c | 43 ++++++++----------- legacy/evas/src/lib/include/evas_common.h | 1 + 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/legacy/evas/src/lib/engines/common/evas_image_load.c b/legacy/evas/src/lib/engines/common/evas_image_load.c index dec999ec01..59361b7bb2 100644 --- a/legacy/evas/src/lib/engines/common/evas_image_load.c +++ b/legacy/evas/src/lib/engines/common/evas_image_load.c @@ -13,7 +13,6 @@ evas_common_load_image_from_file(const char *file, const char *key, RGBA_Image_L char *loader = NULL; Evas_Module *em; struct stat st; -// time_t t; if (file == NULL) return NULL; @@ -23,14 +22,13 @@ evas_common_load_image_from_file(const char *file, const char *key, RGBA_Image_L evas_common_image_ref(im); return im; } -// t = time(); if (stat(file, &st) < 0) return NULL; im = evas_common_image_new(); if (!im) return NULL; im->timestamp = st.st_mtime; -// im->last_stat = t; + im->laststat = time(NULL); if (lo) im->load_opts = *lo; diff --git a/legacy/evas/src/lib/engines/common/evas_image_main.c b/legacy/evas/src/lib/engines/common/evas_image_main.c index 465d95c72b..2a80d3e58d 100644 --- a/legacy/evas/src/lib/engines/common/evas_image_main.c +++ b/legacy/evas/src/lib/engines/common/evas_image_main.c @@ -478,7 +478,7 @@ evas_common_image_find(const char *file, const char *key, DATA64 timestamp, RGBA char buf[4096 + 1024]; Evas_Object_List *l; struct stat st; - static time_t last_stat = 0; + static time_t laststat = 0; time_t t, mt = 0; if ((!file) && (!key)) return NULL; @@ -501,13 +501,13 @@ evas_common_image_find(const char *file, const char *key, DATA64 timestamp, RGBA else snprintf(buf, sizeof(buf), "//@/%i/%1.5f/%ix%i//%s", lo->scale_down_by, lo->dpi, lo->w, lo->h, file); } -// t = time(); im = evas_hash_find(images, buf); + t = time(NULL); if (im) { -// if ((t - im->last_stat) < STAT_GAP) -// return im; -// else + if ((t - im->laststat) < STAT_GAP) + return im; + else { struct stat st; @@ -515,20 +515,12 @@ evas_common_image_find(const char *file, const char *key, DATA64 timestamp, RGBA mt = st.st_mtime; if (mt == im->timestamp) { -// im->last_stat = t; + im->laststat = t; + laststat = t; return im; } } } - else - { -// if ((t - last_stat) >= STAT_GAP) -// { - if (stat(file, &st) < 0) return NULL; - mt = st.st_mtime; -// } - } - for (l = cache; l; l = l->next) { int ok; @@ -550,21 +542,24 @@ evas_common_image_find(const char *file, const char *key, DATA64 timestamp, RGBA ok++; else continue; -// if ((t - im->last_stat) >= STAT_GAP) -// { - if (im->timestamp == mt) - ok++; - else continue; -// } -// else ok++; - if ((lo->scale_down_by == lo2->scale_down_by) && (lo->dpi == lo2->dpi) && (lo->w == lo2->w) && (lo->h == lo2->h)) ok++; else continue; -// im->last_stat = t; + if ((t - im->laststat) >= STAT_GAP) + { + if (stat(file, &st) < 0) continue; + mt = st.st_mtime; + if (im->timestamp == mt) + ok++; + else continue; + } + else ok++; + + laststat = t; + im->laststat = t; return im; } /* diff --git a/legacy/evas/src/lib/include/evas_common.h b/legacy/evas/src/lib/include/evas_common.h index b069df9d5d..3321145c18 100644 --- a/legacy/evas/src/lib/include/evas_common.h +++ b/legacy/evas/src/lib/include/evas_common.h @@ -47,6 +47,7 @@ #include #include #include +#include #include #ifdef HAVE_ALLOCA_H