We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
endsWith()
1 parent 4db4304 commit 39fe3b6Copy full SHA for 39fe3b6
simplecpp.cpp
@@ -138,7 +138,10 @@ static unsigned long long stringToULL(const std::string &s)
138
139
static bool endsWith(const std::string &s, const std::string &e)
140
{
141
- 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
142
+ // but in our case it leads to a big performance regression
143
+ //return (s.size() >= e.size()) && std::equal(e.rbegin(), e.rend(), s.rbegin());
144
+ return (s.size() >= e.size() && s.compare(s.size() - e.size(), e.size(), e) == 0);
145
}
146
147
static bool sameline(const simplecpp::Token *tok1, const simplecpp::Token *tok2)
0 commit comments