From: BALATON Zoltan <[email protected]> Avoid calculating index at every step when we can just count the position.
Signed-off-by: BALATON Zoltan <[email protected]> Reviewed-by: Chad Jablonski <[email protected]> Message-ID: <90b49357b6bf80bcf8962331575ffd16a96b706a.1773009887.git.bala...@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <[email protected]> --- hw/display/ati.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/display/ati.c b/hw/display/ati.c index bb9e0bba282..2c649e940b3 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -198,7 +198,7 @@ static void ati_cursor_draw_line(VGACommonState *vga, uint8_t *d, int scr_y) ATIVGAState *s = container_of(vga, ATIVGAState, vga); uint32_t srcoff; uint32_t *dp = (uint32_t *)d; - int i, j, h; + int i, j, h, idx = 0; if (!(s->regs.crtc_gen_cntl & CRTC2_CUR_EN) || scr_y < vga->hw_cursor_y || scr_y >= vga->hw_cursor_y + 64 || @@ -213,10 +213,10 @@ static void ati_cursor_draw_line(VGACommonState *vga, uint8_t *d, int scr_y) uint32_t color; uint8_t abits = vga_read_byte(vga, srcoff + i); uint8_t xbits = vga_read_byte(vga, srcoff + i + 8); - for (j = 0; j < 8; j++, abits <<= 1, xbits <<= 1) { + for (j = 0; j < 8; j++, abits <<= 1, xbits <<= 1, idx++) { if (abits & BIT(7)) { if (xbits & BIT(7)) { - color = dp[i * 8 + j] ^ 0xffffffff; /* complement */ + color = dp[idx] ^ 0xffffffff; /* complement */ } else { continue; /* transparent, no change */ } @@ -224,10 +224,10 @@ static void ati_cursor_draw_line(VGACommonState *vga, uint8_t *d, int scr_y) color = (xbits & BIT(7) ? s->regs.cur_color1 : s->regs.cur_color0) | 0xff000000; } - if (vga->hw_cursor_x + i * 8 + j >= h) { + if (vga->hw_cursor_x + idx >= h) { return; /* end of screen, don't span to next line */ } - dp[i * 8 + j] = color; + dp[idx] = color; } } } -- 2.53.0
