Cut down on some gratuitous memory allocations in the GUI
This was SVN commit r7256.
This commit is contained in:
parent
8dca5f7320
commit
caf2f72901
@ -104,11 +104,19 @@ void CButton::Draw()
|
||||
CGUISpriteInstance *sprite, *sprite_over, *sprite_pressed, *sprite_disabled;
|
||||
int cell_id;
|
||||
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite", sprite);
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_over", sprite_over);
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_pressed", sprite_pressed);
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_disabled", sprite_disabled);
|
||||
GUI<int>::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<CGUISpriteInstance>::GetSettingPointer(this, strSprite, sprite);
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, strSpriteOver, sprite_over);
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, strSpritePressed, sprite_pressed);
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, strSpriteDisabled, sprite_disabled);
|
||||
GUI<int>::GetSetting(this, strCellId, cell_id);
|
||||
|
||||
DrawButton(m_CachedActualSize,
|
||||
bz,
|
||||
|
@ -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<bool>::GetSetting(pObject, "hidden", hidden);
|
||||
GUI<bool>::GetSetting(pObject, strHidden, hidden);
|
||||
|
||||
if (hidden)
|
||||
return true;
|
||||
@ -352,7 +358,7 @@ private:
|
||||
if (RR & GUIRR_DISABLED)
|
||||
{
|
||||
bool enabled;
|
||||
GUI<bool>::GetSetting(pObject, "enabled", enabled);
|
||||
GUI<bool>::GetSetting(pObject, strEnabled, enabled);
|
||||
|
||||
if (!enabled)
|
||||
return true;
|
||||
@ -360,7 +366,7 @@ private:
|
||||
if (RR & GUIRR_GHOST)
|
||||
{
|
||||
bool ghost;
|
||||
GUI<bool>::GetSetting(pObject, "ghost", ghost);
|
||||
GUI<bool>::GetSetting(pObject, strGhost, ghost);
|
||||
|
||||
if (ghost)
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user