From: Francesco Montorsi Date: Sun, 30 Mar 2008 15:50:40 +0000 (+0000) Subject: optimization for faster execution: don't use wxString::Replace() all the times a... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/658d98040dc6c7146c9c1ef651c7e5c0ebe83ec7 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 --- diff --git a/utils/ifacecheck/src/xmlparser.cpp b/utils/ifacecheck/src/xmlparser.cpp index c91695a4bd..1f2b35da79 100644 --- a/utils/ifacecheck/src/xmlparser.cpp +++ b/utils/ifacecheck/src/xmlparser.cpp @@ -74,6 +74,15 @@ void wxType::SetTypeFromString(const wxString& t) m_strType.Replace(" ,", ","); 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 @@ -82,25 +91,14 @@ bool wxType::IsOk() const // "reverse_iterator_impl" type // It can also contain commas, * and & operators etc - return !GetClean().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); + return !m_strTypeClean.IsEmpty(); } bool wxType::operator==(const wxType& m) const { // brain-dead comparison: - if (GetClean() == m.GetClean() && + if (m_strTypeClean == m.m_strTypeClean && IsConst() == m.IsConst() && IsStatic() == m.IsStatic() && IsPointer() == m.IsPointer() && diff --git a/utils/ifacecheck/src/xmlparser.h b/utils/ifacecheck/src/xmlparser.h index acf2ca7d72..f160c79b3f 100644 --- a/utils/ifacecheck/src/xmlparser.h +++ b/utils/ifacecheck/src/xmlparser.h @@ -55,10 +55,9 @@ public: bool IsOk() const; protected: - wxString m_strType; - - // utility for doing comparisons - wxString GetClean() const; + wxString m_strType, + m_strTypeClean; // m_strType "cleaned" of its attributes + // (only for internal use) }; extern wxType wxEmptyType;