image.c: Minor refactoring of pixmap cache cleaners

This commit is contained in:
Kim Woelders 2019-12-24 09:13:35 +01:00
parent a7be91805f
commit 002df3c1fa
1 changed files with 16 additions and 22 deletions

View File

@ -273,7 +273,6 @@ __imlib_CleanupImageCache(void)
{ {
ImlibImage *im, *im_last; ImlibImage *im, *im_last;
int current_cache; int current_cache;
char operation = 1;
current_cache = __imlib_CurrentCacheSize(); current_cache = __imlib_CurrentCacheSize();
im_last = NULL; im_last = NULL;
@ -291,10 +290,9 @@ __imlib_CleanupImageCache(void)
} }
/* while the cache size of 0 ref coutn data is bigger than the set value */ /* while the cache size of 0 ref coutn data is bigger than the set value */
/* clean out the oldest members of the imaeg cache */ /* clean out the oldest members of the imaeg cache */
while ((current_cache > cache_size) && (operation)) while (current_cache > cache_size)
{ {
im_last = NULL; im_last = NULL;
operation = 0;
im = images; im = images;
while (im) while (im)
{ {
@ -302,14 +300,13 @@ __imlib_CleanupImageCache(void)
im_last = im; im_last = im;
im = im->next; im = im->next;
} }
if (im_last) if (!im_last)
{ break;
__imlib_RemoveImageFromCache(im_last);
__imlib_ConsumeImage(im_last); __imlib_RemoveImageFromCache(im_last);
operation = 1; __imlib_ConsumeImage(im_last);
}
if (operation) current_cache = __imlib_CurrentCacheSize();
current_cache = __imlib_CurrentCacheSize();
} }
} }
@ -459,7 +456,6 @@ __imlib_CleanupImagePixmapCache(void)
{ {
ImlibImagePixmap *ip, *ip_last; ImlibImagePixmap *ip, *ip_last;
int current_cache; int current_cache;
char operation = 1;
current_cache = __imlib_CurrentCacheSize(); current_cache = __imlib_CurrentCacheSize();
ip_last = NULL; ip_last = NULL;
@ -474,10 +470,9 @@ __imlib_CleanupImagePixmapCache(void)
__imlib_ConsumeImagePixmap(ip_last); __imlib_ConsumeImagePixmap(ip_last);
} }
} }
while ((current_cache > cache_size) && (operation)) while (current_cache > cache_size)
{ {
ip_last = NULL; ip_last = NULL;
operation = 0;
ip = pixmaps; ip = pixmaps;
while (ip) while (ip)
{ {
@ -485,14 +480,13 @@ __imlib_CleanupImagePixmapCache(void)
ip_last = ip; ip_last = ip;
ip = ip->next; ip = ip->next;
} }
if (ip_last) if (!ip_last)
{ break;
__imlib_RemoveImagePixmapFromCache(ip_last);
__imlib_ConsumeImagePixmap(ip_last); __imlib_RemoveImagePixmapFromCache(ip_last);
operation = 1; __imlib_ConsumeImagePixmap(ip_last);
}
if (operation) current_cache = __imlib_CurrentCacheSize();
current_cache = __imlib_CurrentCacheSize();
} }
} }
#endif #endif