diff --git a/source/gui/CButton.cpp b/source/gui/CButton.cpp index aafa70175d..ec33c6b9cf 100644 --- a/source/gui/CButton.cpp +++ b/source/gui/CButton.cpp @@ -104,11 +104,19 @@ void CButton::Draw() CGUISpriteInstance *sprite, *sprite_over, *sprite_pressed, *sprite_disabled; int cell_id; - GUI::GetSettingPointer(this, "sprite", sprite); - GUI::GetSettingPointer(this, "sprite_over", sprite_over); - GUI::GetSettingPointer(this, "sprite_pressed", sprite_pressed); - GUI::GetSettingPointer(this, "sprite_disabled", sprite_disabled); - GUI::GetSetting(this, "cell_id", cell_id); + // Statically initialise some strings, so we don't have to do + // lots of allocation every time this function is called + static CStr strSprite("sprite"); + static CStr strSpriteOver("sprite_over"); + static CStr strSpritePressed("sprite_pressed"); + static CStr strSpriteDisabled("sprite_disabled"); + static CStr strCellId("cell_id"); + + GUI::GetSettingPointer(this, strSprite, sprite); + GUI::GetSettingPointer(this, strSpriteOver, sprite_over); + GUI::GetSettingPointer(this, strSpritePressed, sprite_pressed); + GUI::GetSettingPointer(this, strSpriteDisabled, sprite_disabled); + GUI::GetSetting(this, strCellId, cell_id); DrawButton(m_CachedActualSize, bz, diff --git a/source/gui/GUIutil.h b/source/gui/GUIutil.h index 6032a6e119..44642ca866 100644 --- a/source/gui/GUIutil.h +++ b/source/gui/GUIutil.h @@ -341,10 +341,16 @@ private: */ static bool CheckIfRestricted(int RR, IGUIObject *pObject) { + // Statically initialise some strings, so we don't have to do + // lots of allocation every time this function is called + static CStr strHidden("hidden"); + static CStr strEnabled("enabled"); + static CStr strGhost("ghost"); + if (RR & GUIRR_HIDDEN) { bool hidden; - GUI::GetSetting(pObject, "hidden", hidden); + GUI::GetSetting(pObject, strHidden, hidden); if (hidden) return true; @@ -352,7 +358,7 @@ private: if (RR & GUIRR_DISABLED) { bool enabled; - GUI::GetSetting(pObject, "enabled", enabled); + GUI::GetSetting(pObject, strEnabled, enabled); if (!enabled) return true; @@ -360,7 +366,7 @@ private: if (RR & GUIRR_GHOST) { bool ghost; - GUI::GetSetting(pObject, "ghost", ghost); + GUI::GetSetting(pObject, strGhost, ghost); if (ghost) return true;