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).
This commit is contained in:
Monty 2009-05-25 03:05:03 -04:00 committed by Sven Neumann
parent 874e16c669
commit 2eaa777314
1 changed files with 3 additions and 3 deletions

View File

@ -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__ */