[gimp] Optimize TILE_DATA_POINTER() macro



commit 2eaa777314e02d018b9c8e0432f9221fe92e4786
Author: Monty <xiphmont gmail com>
Date:   Mon May 25 03:05:03 2009 -0400

    Optimize TILE_DATA_POINTER() macro
    
    Minor change to TILE_DATA_POINTER that restricts TILE_WIDTH and
    TILE_HEIGHT to powers of two, but eliminates two integer divisions
    (or, in reality, eliminates the over-complicated assembly resulting
    from optimizing out two integer divisions in a C compliant fashion).
---
 app/base/tile-private.h |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/app/base/tile-private.h b/app/base/tile-private.h
index 1cc8565..8021278 100644
--- a/app/base/tile-private.h
+++ b/app/base/tile-private.h
@@ -77,10 +77,10 @@ struct _Tile
 
 
 /*  tile_data_pointer() as a macro so that it can be inlined  */
-
+/*  note that (y) & (TILE_HEIGHT-1) is equivalent to (y) % TILE_HEIGHT 
+    for positive power-of-two divisors */
 #define TILE_DATA_POINTER(tile,x,y) \
   ((tile)->data + \
-   (((y) % TILE_HEIGHT) * (tile)->ewidth + ((x) % TILE_WIDTH)) * (tile)->bpp)
-
+   (((y) & (TILE_HEIGHT-1)) * (tile)->ewidth + ((x) & (TILE_WIDTH-1))) * (tile)->bpp)
 
 #endif /* __TILE_PRIVATE_H__ */



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