mirror of
https://github.com/znc/znc.git
synced 2026-08-07 17:33:34 +02:00
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:
+18
-12
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user