Make CString::Trim*() faster

Before, they would remove one character at a time.
Now they do everything at once.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1322 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2009-01-06 09:43:18 +00:00
parent 9933ba9c3e
commit f5eff8196f
+18 -12
View File
@@ -937,25 +937,31 @@ bool CString::Trim(const CString& s) {
}
bool CString::TrimLeft(const CString& s) {
bool bRet = false;
size_type i = find_first_not_of(s);
while (length() && s.find(Left(1)) != CString::npos) {
LeftChomp();
bRet = true;
}
if (i == 0)
return false;
return bRet;
if (i != npos)
this->erase(0, i);
else
this->clear();
return true;
}
bool CString::TrimRight(const CString& s) {
bool bRet = false;
size_type i = find_last_not_of(s);
while (length() && s.find(Right(1)) != CString::npos) {
RightChomp();
bRet = true;
}
if (i + 1 == length())
return false;
return bRet;
if (i != npos)
this->erase(i + 1, npos);
else
this->clear();
return true;
}
CString CString::Trim_n(const CString& s) const {