]> git.saurik.com Git - wxWidgets.git/commitdiff
don't call CopyBeforeWrite when returning non-const interator if the string is empty...
authorVáclav Slavík <vslavik@fastmail.fm>
Mon, 31 May 2004 22:05:59 +0000 (22:05 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Mon, 31 May 2004 22:05:59 +0000 (22:05 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27539 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/string.h
src/common/string.cpp

index 6667f8fae8715f5b7d84e784a6c0f88ef1956895..2ae008571933a2ba4d545ee2b72bcc60e5464ebe 100644 (file)
@@ -429,9 +429,9 @@ public:
   const_iterator end() const { return m_pchData + length(); }
 
   // first valid index position
-  iterator begin() { CopyBeforeWrite(); return m_pchData; }
+  iterator begin();
   // position one after the last valid one
-  iterator end() { CopyBeforeWrite(); return m_pchData + length(); }
+  iterator end();
 
     // insert another string
   wxStringBase& insert(size_t nPos, const wxStringBase& str)
index 9b1de655cd4fd2f4a483506675861972b2383b8b..70473982fdcaec8055814ff41f2174964001c95a 100644 (file)
@@ -407,6 +407,20 @@ bool wxStringBase::Alloc(size_t nLen)
   //else: we've already got enough
   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)
 {