bogus assert removed, optimized (and removed a bug in process of doing it)
wxString::Trim git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@799 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -257,10 +257,10 @@ public:
|
||||
size_t Len() const { return GetStringData()->nDataLength; }
|
||||
/// string contains any characters?
|
||||
bool IsEmpty() const { return Len() == 0; }
|
||||
/// reinitialize string (and free data!)
|
||||
/// reinitialize string (and free memory)
|
||||
void Empty()
|
||||
{
|
||||
if ( GetStringData()->nDataLength != 0 )
|
||||
if ( !IsEmpty() )
|
||||
Reinit();
|
||||
|
||||
wxASSERT( GetStringData()->nDataLength == 0 );
|
||||
|
@@ -775,6 +775,15 @@ wxString& wxString::MakeLower()
|
||||
// trims spaces (in the sense of isspace) from left or right side
|
||||
wxString& wxString::Trim(bool bFromRight)
|
||||
{
|
||||
// first check if we're going to modify the string at all
|
||||
if ( !IsEmpty() &&
|
||||
(
|
||||
(bFromRight && isspace(GetChar(Len() - 1))) ||
|
||||
(!bFromRight && isspace(GetChar(0u)))
|
||||
)
|
||||
)
|
||||
{
|
||||
// ok, there is at least one space to trim
|
||||
CopyBeforeWrite();
|
||||
|
||||
if ( bFromRight )
|
||||
@@ -800,6 +809,7 @@ wxString& wxString::Trim(bool bFromRight)
|
||||
memmove(m_pchData, psz, (nDataLength + 1)*sizeof(char));
|
||||
GetStringData()->nDataLength = nDataLength;
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
Reference in New Issue
Block a user