ltrim and rtrim take argument by const-ref
This commit is contained in:
parent
061cb76fc4
commit
2697d432a4
|
@ -4,12 +4,12 @@
|
||||||
|
|
||||||
const std::string WHITESPACE = " \n\r\t\f\v";
|
const std::string WHITESPACE = " \n\r\t\f\v";
|
||||||
|
|
||||||
inline std::string ltrim(const std::string s) {
|
inline std::string ltrim(const std::string& s) {
|
||||||
size_t begin = s.find_first_not_of(WHITESPACE);
|
size_t begin = s.find_first_not_of(WHITESPACE);
|
||||||
return (begin == std::string::npos) ? "" : s.substr(begin);
|
return (begin == std::string::npos) ? "" : s.substr(begin);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string rtrim(const std::string s) {
|
inline std::string rtrim(const std::string& s) {
|
||||||
size_t end = s.find_last_not_of(WHITESPACE);
|
size_t end = s.find_last_not_of(WHITESPACE);
|
||||||
return (end == std::string::npos) ? "" : s.substr(0, end + 1);
|
return (end == std::string::npos) ? "" : s.substr(0, end + 1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue