optimization for faster execution: don't use wxString::Replace() all the times a wxType comparison is required
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52923 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -74,6 +74,15 @@ void wxType::SetTypeFromString(const wxString& t)
|
|||||||
m_strType.Replace(" ,", ",");
|
m_strType.Replace(" ,", ",");
|
||||||
|
|
||||||
m_strType = m_strType.Strip(wxString::both);
|
m_strType = m_strType.Strip(wxString::both);
|
||||||
|
|
||||||
|
// now set the clean version
|
||||||
|
m_strTypeClean = m_strType;
|
||||||
|
m_strTypeClean.Replace("const", "");
|
||||||
|
m_strTypeClean.Replace("static", "");
|
||||||
|
m_strTypeClean.Replace("*", "");
|
||||||
|
m_strTypeClean.Replace("&", "");
|
||||||
|
m_strTypeClean.Replace("[]", "");
|
||||||
|
m_strTypeClean = m_strTypeClean.Strip(wxString::both);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxType::IsOk() const
|
bool wxType::IsOk() const
|
||||||
@@ -82,25 +91,14 @@ bool wxType::IsOk() const
|
|||||||
// "reverse_iterator_impl<wxString::const_iterator>" type
|
// "reverse_iterator_impl<wxString::const_iterator>" type
|
||||||
// It can also contain commas, * and & operators etc
|
// It can also contain commas, * and & operators etc
|
||||||
|
|
||||||
return !GetClean().IsEmpty();
|
return !m_strTypeClean.IsEmpty();
|
||||||
}
|
|
||||||
|
|
||||||
wxString wxType::GetClean() const
|
|
||||||
{
|
|
||||||
wxString ret(m_strType);
|
|
||||||
ret.Replace("const", "");
|
|
||||||
ret.Replace("static", "");
|
|
||||||
ret.Replace("*", "");
|
|
||||||
ret.Replace("&", "");
|
|
||||||
ret.Replace("[]", "");
|
|
||||||
return ret.Strip(wxString::both);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxType::operator==(const wxType& m) const
|
bool wxType::operator==(const wxType& m) const
|
||||||
{
|
{
|
||||||
// brain-dead comparison:
|
// brain-dead comparison:
|
||||||
|
|
||||||
if (GetClean() == m.GetClean() &&
|
if (m_strTypeClean == m.m_strTypeClean &&
|
||||||
IsConst() == m.IsConst() &&
|
IsConst() == m.IsConst() &&
|
||||||
IsStatic() == m.IsStatic() &&
|
IsStatic() == m.IsStatic() &&
|
||||||
IsPointer() == m.IsPointer() &&
|
IsPointer() == m.IsPointer() &&
|
||||||
|
@@ -55,10 +55,9 @@ public:
|
|||||||
bool IsOk() const;
|
bool IsOk() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxString m_strType;
|
wxString m_strType,
|
||||||
|
m_strTypeClean; // m_strType "cleaned" of its attributes
|
||||||
// utility for doing comparisons
|
// (only for internal use)
|
||||||
wxString GetClean() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern wxType wxEmptyType;
|
extern wxType wxEmptyType;
|
||||||
|
Reference in New Issue
Block a user