Avoid consecutive calls of wxVariant::GetType() in the multiple-branch conditional statements.

This is a minor optimization since wxVariant::GetType() is not a simple inline getter method.
This commit is contained in:
Artur Wieczorek
2015-02-28 16:35:20 +01:00
parent 3fb1827c93
commit 2f239930eb
2 changed files with 16 additions and 14 deletions

View File

@@ -975,7 +975,8 @@ wxColourPropertyValue wxSystemColourProperty::GetVal( const wxVariant* pVariant
if ( pVariant->IsNull() )
return wxColourPropertyValue(wxPG_COLOUR_UNSPECIFIED, wxColour());
if ( pVariant->GetType() == wxS("wxColourPropertyValue") )
const wxString valType(pVariant->GetType());
if ( valType == wxS("wxColourPropertyValue") )
{
wxColourPropertyValue v;
v << *pVariant;
@@ -985,16 +986,16 @@ wxColourPropertyValue wxSystemColourProperty::GetVal( const wxVariant* pVariant
wxColour col;
bool variantProcessed = true;
if ( pVariant->GetType() == wxS("wxColour*") )
if ( valType == wxS("wxColour*") )
{
wxColour* pCol = wxStaticCast(pVariant->GetWxObjectPtr(), wxColour);
col = *pCol;
}
else if ( pVariant->GetType() == wxS("wxColour") )
else if ( valType == wxS("wxColour") )
{
col << *pVariant;
}
else if ( pVariant->GetType() == wxArrayInt_VariantType )
else if ( valType == wxArrayInt_VariantType )
{
// This code is mostly needed for wxPython bindings, which
// may offer tuple of integers as colour value.