forked from enlightenment/efl
now limit stats per any 1 file to STAT_GAP (2 seconds).
SVN revision: 28544
This commit is contained in:
parent
63a4cbb869
commit
921304555c
|
@ -13,7 +13,6 @@ evas_common_load_image_from_file(const char *file, const char *key, RGBA_Image_L
|
||||||
char *loader = NULL;
|
char *loader = NULL;
|
||||||
Evas_Module *em;
|
Evas_Module *em;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
// time_t t;
|
|
||||||
|
|
||||||
if (file == NULL) return NULL;
|
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);
|
evas_common_image_ref(im);
|
||||||
return im;
|
return im;
|
||||||
}
|
}
|
||||||
// t = time();
|
|
||||||
if (stat(file, &st) < 0) return NULL;
|
if (stat(file, &st) < 0) return NULL;
|
||||||
|
|
||||||
im = evas_common_image_new();
|
im = evas_common_image_new();
|
||||||
if (!im) return NULL;
|
if (!im) return NULL;
|
||||||
|
|
||||||
im->timestamp = st.st_mtime;
|
im->timestamp = st.st_mtime;
|
||||||
// im->last_stat = t;
|
im->laststat = time(NULL);
|
||||||
|
|
||||||
if (lo) im->load_opts = *lo;
|
if (lo) im->load_opts = *lo;
|
||||||
|
|
||||||
|
|
|
@ -478,7 +478,7 @@ evas_common_image_find(const char *file, const char *key, DATA64 timestamp, RGBA
|
||||||
char buf[4096 + 1024];
|
char buf[4096 + 1024];
|
||||||
Evas_Object_List *l;
|
Evas_Object_List *l;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
static time_t last_stat = 0;
|
static time_t laststat = 0;
|
||||||
time_t t, mt = 0;
|
time_t t, mt = 0;
|
||||||
|
|
||||||
if ((!file) && (!key)) return NULL;
|
if ((!file) && (!key)) return NULL;
|
||||||
|
@ -501,13 +501,13 @@ evas_common_image_find(const char *file, const char *key, DATA64 timestamp, RGBA
|
||||||
else
|
else
|
||||||
snprintf(buf, sizeof(buf), "//@/%i/%1.5f/%ix%i//%s", lo->scale_down_by, lo->dpi, lo->w, lo->h, file);
|
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);
|
im = evas_hash_find(images, buf);
|
||||||
|
t = time(NULL);
|
||||||
if (im)
|
if (im)
|
||||||
{
|
{
|
||||||
// if ((t - im->last_stat) < STAT_GAP)
|
if ((t - im->laststat) < STAT_GAP)
|
||||||
// return im;
|
return im;
|
||||||
// else
|
else
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
|
@ -515,20 +515,12 @@ evas_common_image_find(const char *file, const char *key, DATA64 timestamp, RGBA
|
||||||
mt = st.st_mtime;
|
mt = st.st_mtime;
|
||||||
if (mt == im->timestamp)
|
if (mt == im->timestamp)
|
||||||
{
|
{
|
||||||
// im->last_stat = t;
|
im->laststat = t;
|
||||||
|
laststat = t;
|
||||||
return im;
|
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)
|
for (l = cache; l; l = l->next)
|
||||||
{
|
{
|
||||||
int ok;
|
int ok;
|
||||||
|
@ -550,21 +542,24 @@ evas_common_image_find(const char *file, const char *key, DATA64 timestamp, RGBA
|
||||||
ok++;
|
ok++;
|
||||||
else continue;
|
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) &&
|
if ((lo->scale_down_by == lo2->scale_down_by) &&
|
||||||
(lo->dpi == lo2->dpi) && (lo->w == lo2->w) &&
|
(lo->dpi == lo2->dpi) && (lo->w == lo2->w) &&
|
||||||
(lo->h == lo2->h))
|
(lo->h == lo2->h))
|
||||||
ok++;
|
ok++;
|
||||||
else continue;
|
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;
|
return im;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <time.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#ifdef HAVE_ALLOCA_H
|
#ifdef HAVE_ALLOCA_H
|
||||||
|
|
Loading…
Reference in New Issue