diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-04-11 21:04:29 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-04-11 21:06:53 +0100 |
commit | d95037db9915033ef1eee24c2fc05e8a95af5457 (patch) | |
tree | 46b7d5532ddd3f2891a9c7d695cbb3343803802f /src/cairo-cache.c | |
parent | e6309c6307179388c5de938bffdb44b83b694f28 (diff) | |
download | cairo-d95037db9915033ef1eee24c2fc05e8a95af5457.tar.gz |
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.
Diffstat (limited to 'src/cairo-cache.c')
-rw-r--r-- | src/cairo-cache.c | 10 |
1 files 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); |