[gegl] buffer: avoid iterating tile cache unnecesarily
- From: Ãyvind KolÃs <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] buffer: avoid iterating tile cache unnecesarily
- Date: Sun, 1 Apr 2012 20:27:50 +0000 (UTC)
commit 0299abd3982ef45f05675d85521136a30e3eb983
Author: Ãyvind KolÃs <pippin gimp org>
Date: Sun Apr 1 21:26:35 2012 +0100
buffer: avoid iterating tile cache unnecesarily
Only iterate the tile cache looking for droppable tiles when the
tile-cache-handler is known to have cached tiles.
Also added a sanity balance check in dispose of cache-handler.
gegl/buffer/gegl-tile-handler-cache.c | 11 +++++++++++
gegl/buffer/gegl-tile-handler-cache.h | 1 +
2 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/gegl/buffer/gegl-tile-handler-cache.c b/gegl/buffer/gegl-tile-handler-cache.c
index 5ad872b..a0675fe 100644
--- a/gegl/buffer/gegl-tile-handler-cache.c
+++ b/gegl/buffer/gegl-tile-handler-cache.c
@@ -128,6 +128,9 @@ gegl_tile_handler_cache_reinit (GeglTileHandlerCache *cache)
CacheItem *item;
GSList *iter;
+ if (!cache->count)
+ return;
+
g_static_mutex_lock (&mutex);
/* only throw out items belonging to this cache instance */
@@ -148,6 +151,7 @@ gegl_tile_handler_cache_reinit (GeglTileHandlerCache *cache)
cache_total -= item->tile->size;
gegl_tile_mark_as_stored (item->tile); /* to avoid saving */
gegl_tile_unref (item->tile);
+ cache->count--;
}
g_queue_remove (cache_queue, item);
g_hash_table_remove (cache_ht, item);
@@ -196,6 +200,7 @@ gegl_tile_handler_cache_dispose (GObject *object)
{
cache_total -= item->tile->size;
gegl_tile_unref (item->tile);
+ cache->count--;
}
g_queue_remove (cache_queue, item);
g_hash_table_remove (cache_ht, item);
@@ -205,6 +210,10 @@ gegl_tile_handler_cache_dispose (GObject *object)
cache->free_list = NULL;
g_static_mutex_unlock (&mutex);
+ if (cache->count != 0)
+ {
+ g_warning ("cache-handler tile balance not zero: %i\n", cache->count);
+ }
G_OBJECT_CLASS (gegl_tile_handler_cache_parent_class)->dispose (object);
}
@@ -502,6 +511,8 @@ gegl_tile_handler_cache_insert (GeglTileHandlerCache *cache,
cache_total += item->tile->size;
g_queue_push_head (cache_queue, item);
+ cache->count ++;
+
g_hash_table_insert (cache_ht, item, item);
while (cache_total > gegl_config()->cache_size)
diff --git a/gegl/buffer/gegl-tile-handler-cache.h b/gegl/buffer/gegl-tile-handler-cache.h
index 81b40fa..c716698 100644
--- a/gegl/buffer/gegl-tile-handler-cache.h
+++ b/gegl/buffer/gegl-tile-handler-cache.h
@@ -41,6 +41,7 @@ struct _GeglTileHandlerCache
GeglTileHandler parent_instance;
GeglTileStorage *tile_storage;
GSList *free_list;
+ int count; /* number of items held by cache */
};
struct _GeglTileHandlerCacheClass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]