Skip to content

Commit 4b31249

Browse files
committed
Simplify string right trim function
1 parent da89f38 commit 4b31249

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

src/ast.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,14 @@ namespace Sass {
3030
Cast<Supports_Operator>(cond);
3131
}
3232

33-
std::string & str_ltrim(std::string & str)
33+
void str_rtrim(std::string& str, const std::string& delimiters = " \f\n\r\t\v")
3434
{
35-
auto it2 = std::find_if( str.begin() , str.end() , [](char ch){ return !std::isspace<char>(ch , std::locale::classic() ) ; } );
36-
str.erase( str.begin() , it2);
37-
return str;
38-
}
39-
40-
std::string & str_rtrim(std::string & str)
41-
{
42-
auto it1 = std::find_if( str.rbegin() , str.rend() , [](char ch){ return !std::isspace<char>(ch , std::locale::classic() ) ; } );
43-
str.erase( it1.base() , str.end() );
44-
return str;
35+
str.erase( str.find_last_not_of( delimiters ) + 1 );
4536
}
4637

4738
void String_Constant::rtrim()
4839
{
49-
value_ = str_rtrim(value_);
40+
str_rtrim(value_);
5041
}
5142

5243
void String_Schema::rtrim()

0 commit comments

Comments
 (0)