From d95037db9915033ef1eee24c2fc05e8a95af5457 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 11 Apr 2010 21:04:29 +0100 Subject: [PATCH] cache: Tidy _cairo_cache_shrink_to_accommodate() There is no need to shrink the cache if we add an entry of size 0, so don't by moving the guards in _cairo_cache_shrink_to_accommodate() to the callers. --- src/cairo-cache.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/cairo-cache.c b/src/cairo-cache.c index 1bc308994..7d998459a 100644 --- a/src/cairo-cache.c +++ b/src/cairo-cache.c @@ -175,9 +175,7 @@ _cairo_cache_thaw (cairo_cache_t *cache) { assert (cache->freeze_count > 0); - cache->freeze_count--; - - if (cache->freeze_count == 0) + if (--cache->freeze_count == 0) _cairo_cache_shrink_to_accommodate (cache, 0); } @@ -241,9 +239,6 @@ static void _cairo_cache_shrink_to_accommodate (cairo_cache_t *cache, unsigned long additional) { - if (cache->freeze_count) - return; - while (cache->size + additional > cache->max_size) { if (! _cairo_cache_remove_random (cache)) return; @@ -268,7 +263,8 @@ _cairo_cache_insert (cairo_cache_t *cache, { cairo_status_t status; - _cairo_cache_shrink_to_accommodate (cache, entry->size); + if (entry->size && ! cache->freeze_count) + _cairo_cache_shrink_to_accommodate (cache, entry->size); status = _cairo_hash_table_insert (cache->hash_table, (cairo_hash_entry_t *) entry);