Skip to content

Commit f967842

Browse files
committed
fixed performance regression in endsWith()
1 parent cfef803 commit f967842

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

simplecpp.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ static unsigned long long stringToULL(const std::string &s)
154154

155155
static bool endsWith(const std::string &s, const std::string &e)
156156
{
157+
// 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() && s.compare(s.size() - e.size(), e.size(), e) == 0);
157160
return (s.size() >= e.size()) && std::equal(e.rbegin(), e.rend(), s.rbegin());
158161
}
159162

0 commit comments

Comments
 (0)