From 5381e7809aab00e2153b687d9453e039a0180832 Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 25 May 2009 03:05:03 -0400 Subject: [PATCH 1/4] 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__ */ -- 1.6.3.1