add cache for last used position and string length to UTF-8 wxString, dramatically improving performance of the code using indices to iterate over strings
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55333 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -100,7 +100,7 @@ wxUniCharRef& wxUniCharRef::operator=(const wxUniChar& c)
|
||||
for ( size_t i = 0; i < lenNew; ++i, ++pos )
|
||||
*pos = utf[i];
|
||||
}
|
||||
else
|
||||
else // length of character encoding in UTF-8 changed
|
||||
{
|
||||
// the worse case is when the new value has either longer or shorter
|
||||
// code -- in that case, we have to use wxStringImpl::replace() and
|
||||
@@ -148,6 +148,10 @@ wxUniCharRef& wxUniCharRef::operator=(const wxUniChar& c)
|
||||
// update the string:
|
||||
strimpl.replace(m_pos, m_pos + lenOld, utf, lenNew);
|
||||
|
||||
#if wxUSE_STRING_POS_CACHE
|
||||
m_str.InvalidateCache();
|
||||
#endif // wxUSE_STRING_POS_CACHE
|
||||
|
||||
// finally, set the iterators to valid values again (note that this
|
||||
// updates m_pos as well):
|
||||
size_t i;
|
||||
|
||||
Reference in New Issue
Block a user