Changeset - r28327:e3129dfe29b1
[Not reviewed]
master
0 1 0
Peter Nelson - 6 months ago 2023-12-22 16:01:32
peter1138@openttd.org
Codechange: Perform simpler comparison first when checking for palette updates.

This avoids unnecessarily comparing contents of an array.
1 file changed with 4 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/gfx.cpp
Show inline comments
 
@@ -1368,12 +1368,10 @@ void DoPaletteAnimations()
 

	
 
	if (blitter != nullptr && blitter->UsePaletteAnimation() == Blitter::PALETTE_ANIMATION_NONE) {
 
		palette_animation_counter = old_tc;
 
	} else {
 
		if (memcmp(old_val, &_cur_palette.palette[PALETTE_ANIM_START], sizeof(old_val)) != 0 && _cur_palette.count_dirty == 0) {
 
			/* Did we changed anything on the palette? Seems so.  Mark it as dirty */
 
			_cur_palette.first_dirty = PALETTE_ANIM_START;
 
			_cur_palette.count_dirty = PALETTE_ANIM_SIZE;
 
		}
 
	} else if (_cur_palette.count_dirty == 0 && memcmp(old_val, &_cur_palette.palette[PALETTE_ANIM_START], sizeof(old_val)) != 0) {
 
		/* Did we changed anything on the palette? Seems so.  Mark it as dirty */
 
		_cur_palette.first_dirty = PALETTE_ANIM_START;
 
		_cur_palette.count_dirty = PALETTE_ANIM_SIZE;
 
	}
 
}
 

	
0 comments (0 inline, 0 general)