mirror of https://github.com/GNOME/gimp.git
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:
parent
874e16c669
commit
2eaa777314
|
@ -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__ */
|
||||
|
|
Loading…
Reference in New Issue