[gegl/soc-2011-warp: 16/31] gegl_tile_iterator: simplify again and remove a goto



commit a88ed39d3197e2b9e22b94dc382c838a551fe0c9
Author: Michael Murà <batolettre gmail com>
Date:   Tue Jul 26 13:31:59 2011 +0200

    gegl_tile_iterator: simplify again and remove a goto

 gegl/buffer/gegl-buffer-access.c |   56 +++++++++++++++----------------------
 1 files changed, 23 insertions(+), 33 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index 1f5a654..e968ced 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -1123,7 +1123,6 @@ gegl_buffer_sample_cleanup (GeglBuffer *buffer)
     }
 }
 
-
 typedef struct GeglBufferTileIterator
 {
   GeglBuffer    *buffer;
@@ -1159,16 +1158,14 @@ gegl_buffer_tile_iterator_next (GeglBufferTileIterator *it)
   GeglBuffer *buffer   = it->buffer;
   gint  tile_width     = buffer->tile_storage->tile_width;
   gint  tile_height    = buffer->tile_storage->tile_height;
-  gint  buffer_shift_x = buffer->shift_x;
-  gint  buffer_shift_y = buffer->shift_y;
-  gint  buffer_x       = buffer->extent.x + buffer_shift_x;
-  gint  buffer_y       = buffer->extent.y + buffer_shift_y;
+  gint  buffer_x       = buffer->extent.x + buffer->shift_x;
+  gint  buffer_y       = buffer->extent.y + buffer->shift_y;
+  gint  tiledx, tiledy;
+  gint  offsetx, offsety;
 
   if (it->roi.width == 0 || it->roi.height == 0)
     return FALSE;
 
-gulp:
-
   /* unref previously held tile */
   if (it->tile)
     {
@@ -1176,40 +1173,33 @@ gulp:
       it->tile = NULL;
     }
 
-  if (it->next_col < it->roi.width)
-    { /* return tile on this row */
-      gint tiledx = buffer_x + it->next_col;
-      gint tiledy = buffer_y + it->next_row;
-      gint offsetx = gegl_tile_offset (tiledx, tile_width);
-      gint offsety = gegl_tile_offset (tiledy, tile_height);
-
-      it->tile = gegl_tile_source_get_tile ((GeglTileSource *) (buffer),
-                                            gegl_tile_indice (tiledx, tile_width),
-                                            gegl_tile_indice (tiledy, tile_height),
-                                            0);
-
-      it->next_col += tile_width - offsetx;
-
-      return TRUE;
-    }
-  else /* move down to next row */
+  /* check if moving to next row is needed */
+  if (it->next_col >= it->roi.width)
     {
-      gint tiledy;
-      gint offsety;
-
       tiledy = buffer_y + it->next_row;
       offsety = gegl_tile_offset (tiledy, tile_height);
 
       it->next_row += tile_height - offsety;
-      it->next_col=0;
+      it->next_col  = 0;
 
-      if (it->next_row < it->roi.height)
-        {
-          goto gulp; /* return the first tile in the next row */
+      if (it->next_row > it->roi.height)
+        { /* iteration ended */
+          return FALSE;
         }
-      return FALSE;
     }
-  return FALSE;
+
+    tiledx = buffer_x + it->next_col;
+    tiledy = buffer_y + it->next_row;
+    offsetx = gegl_tile_offset (tiledx, tile_width);
+
+    it->tile = gegl_tile_source_get_tile ((GeglTileSource *) (buffer),
+                                          gegl_tile_indice (tiledx, tile_width),
+                                          gegl_tile_indice (tiledy, tile_height),
+                                          0);
+
+    it->next_col += tile_width - offsetx;
+
+    return TRUE;
 }
 
 void



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