don't call CopyBeforeWrite when returning non-const interator if the string is empty -- avoids assert and is not needed anyway since the iterator is never valid

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27539 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2004-05-31 22:05:59 +00:00
parent 0dc6da2d7d
commit ac3c86ee7d
2 changed files with 16 additions and 2 deletions

View File

@@ -429,9 +429,9 @@ public:
const_iterator end() const { return m_pchData + length(); } const_iterator end() const { return m_pchData + length(); }
// first valid index position // first valid index position
iterator begin() { CopyBeforeWrite(); return m_pchData; } iterator begin();
// position one after the last valid one // position one after the last valid one
iterator end() { CopyBeforeWrite(); return m_pchData + length(); } iterator end();
// insert another string // insert another string
wxStringBase& insert(size_t nPos, const wxStringBase& str) wxStringBase& insert(size_t nPos, const wxStringBase& str)

View File

@@ -407,6 +407,20 @@ bool wxStringBase::Alloc(size_t nLen)
//else: we've already got enough //else: we've already got enough
return TRUE; return TRUE;
} }
wxStringBase::iterator wxStringBase::begin()
{
if (length() > 0)
CopyBeforeWrite();
return m_pchData;
}
wxStringBase::iterator wxStringBase::end()
{
if (length() > 0)
CopyBeforeWrite();
return m_pchData + length();
}
wxStringBase::iterator wxStringBase::erase(iterator it) wxStringBase::iterator wxStringBase::erase(iterator it)
{ {