diff options
author | Kim Woelders <kim@woelders.dk> | 2019-12-24 09:13:35 +0100 |
---|---|---|
committer | Kim Woelders <kim@woelders.dk> | 2019-12-28 12:06:22 +0100 |
commit | 002df3c1fa24e600a06f64264178d808b7b9ddb5 (patch) | |
tree | e1fda625fa303313fc716b53ece6de0aaa3c0fff | |
parent | a7be91805fe7e8c11786ff9d6ae663f999fa232a (diff) | |
download | imlib2-002df3c1fa24e600a06f64264178d808b7b9ddb5.tar.gz |
image.c: Minor refactoring of pixmap cache cleaners
-rw-r--r-- | src/lib/image.c | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/src/lib/image.c b/src/lib/image.c index c1c83f4..f45929d 100644 --- a/src/lib/image.c +++ b/src/lib/image.c @@ -273,7 +273,6 @@ __imlib_CleanupImageCache(void) { ImlibImage *im, *im_last; int current_cache; - char operation = 1; current_cache = __imlib_CurrentCacheSize(); 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 */ /* clean out the oldest members of the imaeg cache */ - while ((current_cache > cache_size) && (operation)) + while (current_cache > cache_size) { im_last = NULL; - operation = 0; im = images; while (im) { @@ -302,14 +300,13 @@ __imlib_CleanupImageCache(void) im_last = im; im = im->next; } - if (im_last) - { - __imlib_RemoveImageFromCache(im_last); - __imlib_ConsumeImage(im_last); - operation = 1; - } - if (operation) - current_cache = __imlib_CurrentCacheSize(); + if (!im_last) + break; + + __imlib_RemoveImageFromCache(im_last); + __imlib_ConsumeImage(im_last); + + current_cache = __imlib_CurrentCacheSize(); } } @@ -459,7 +456,6 @@ __imlib_CleanupImagePixmapCache(void) { ImlibImagePixmap *ip, *ip_last; int current_cache; - char operation = 1; current_cache = __imlib_CurrentCacheSize(); ip_last = NULL; @@ -474,10 +470,9 @@ __imlib_CleanupImagePixmapCache(void) __imlib_ConsumeImagePixmap(ip_last); } } - while ((current_cache > cache_size) && (operation)) + while (current_cache > cache_size) { ip_last = NULL; - operation = 0; ip = pixmaps; while (ip) { @@ -485,14 +480,13 @@ __imlib_CleanupImagePixmapCache(void) ip_last = ip; ip = ip->next; } - if (ip_last) - { - __imlib_RemoveImagePixmapFromCache(ip_last); - __imlib_ConsumeImagePixmap(ip_last); - operation = 1; - } - if (operation) - current_cache = __imlib_CurrentCacheSize(); + if (!ip_last) + break; + + __imlib_RemoveImagePixmapFromCache(ip_last); + __imlib_ConsumeImagePixmap(ip_last); + + current_cache = __imlib_CurrentCacheSize(); } } #endif |