We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
endsWith()
1 parent cfef803 commit f02a68aCopy full SHA for f02a68a
simplecpp.cpp
@@ -154,7 +154,10 @@ static unsigned long long stringToULL(const std::string &s)
154
155
static bool endsWith(const std::string &s, const std::string &e)
156
{
157
- return (s.size() >= e.size()) && std::equal(e.rbegin(), e.rend(), s.rbegin());
+ // TODO: std::equal() is much faster than std::string::compare() in a benchmark
158
+ // but in our case it leads to a big performance regression
159
+ //return (s.size() >= e.size()) && std::equal(e.rbegin(), e.rend(), s.rbegin());
160
+ return (s.size() >= e.size() && s.compare(s.size() - e.size(), e.size(), e) == 0);
161
}
162
163
static bool sameline(const simplecpp::Token *tok1, const simplecpp::Token *tok2)
0 commit comments