From 3fddf4dfef9f77390ba8426d119c3eb94dadd099 Mon Sep 17 00:00:00 2001 From: David Capello Date: Thu, 10 Jan 2019 16:19:46 -0300 Subject: [PATCH] lua: Avoid cmd::SetPalette() when there is nothing to change --- src/app/script/palette_class.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/app/script/palette_class.cpp b/src/app/script/palette_class.cpp index caaa72483..82d1eef8c 100644 --- a/src/app/script/palette_class.cpp +++ b/src/app/script/palette_class.cpp @@ -97,9 +97,11 @@ int Palette_resize(lua_State* L) Palette newPal(*pal); newPal.resize(ncolors); - Tx tx; - tx(new cmd::SetPalette(sprite, pal->frame(), &newPal)); - tx.commit(); + if (*pal != newPal) { + Tx tx; + tx(new cmd::SetPalette(sprite, pal->frame(), &newPal)); + tx.commit(); + } } else pal->resize(ncolors); @@ -135,6 +137,10 @@ int Palette_setColor(lua_State* L) doc::color_t docColor = convert_args_into_pixel_color(L, 3); if (auto sprite = obj->sprite(L)) { + // Nothing to do + if (pal->getEntry(i) == docColor) + return 0; + Palette newPal(*pal); newPal.setEntry(i, docColor);