[gegl] BackendSwap: Avoid allocation in get_tile



commit eae6e51fad197089cf104ac9c7750eb1fcc07041
Author: Daniel Sabo <DanielSabo gmail com>
Date:   Thu Mar 13 21:53:50 2014 -0700

    BackendSwap: Avoid allocation in get_tile
    
    Allocating the key on the stack makes the performance identical
    to backend ram when nothing has been swapped.

 gegl/buffer/gegl-tile-backend-swap.c |   14 +++-----------
 1 files changed, 3 insertions(+), 11 deletions(-)
---
diff --git a/gegl/buffer/gegl-tile-backend-swap.c b/gegl/buffer/gegl-tile-backend-swap.c
index 819a7dd..50a34a0 100644
--- a/gegl/buffer/gegl-tile-backend-swap.c
+++ b/gegl/buffer/gegl-tile-backend-swap.c
@@ -574,13 +574,9 @@ gegl_tile_backend_swap_lookup_entry (GeglTileBackendSwap *self,
                                      gint                 y,
                                      gint                 z)
 {
-  SwapEntry *ret = NULL;
-  SwapEntry *key = gegl_tile_backend_swap_entry_create (x, y, z);
+  SwapEntry key = {0, NULL, x, y, z};
 
-  ret = g_hash_table_lookup (self->index, key);
-  g_slice_free (SwapEntry, key);
-
-  return ret;
+  return g_hash_table_lookup (self->index, &key);
 }
 
 static GeglTile *
@@ -589,14 +585,12 @@ gegl_tile_backend_swap_get_tile (GeglTileSource *self,
                                  gint            y,
                                  gint            z)
 {
-  GeglTileBackend     *backend;
   GeglTileBackendSwap *tile_backend_swap;
   SwapEntry           *entry;
   GeglTile            *tile = NULL;
   gint                 tile_size;
 
-  backend           = GEGL_TILE_BACKEND (self);
-  tile_backend_swap = GEGL_TILE_BACKEND_SWAP (backend);
+  tile_backend_swap = GEGL_TILE_BACKEND_SWAP (self);
   entry             = gegl_tile_backend_swap_lookup_entry (tile_backend_swap, x, y, z);
 
   if (!entry)
@@ -763,8 +757,6 @@ gegl_tile_backend_swap_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  backend->priv->shared = FALSE;
-
   gegl_tile_backend_set_flush_on_destroy (backend, FALSE);
 
   GEGL_NOTE (GEGL_DEBUG_TILE_BACKEND, "constructing swap backend");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]