mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-07 01:38:38 +02:00
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.
This commit is contained in:
parent
e6309c6307
commit
d95037db99
1 changed files with 3 additions and 7 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue