abseil-string-find-startswith.rst
966 Bytes
abseil-string-find-startswith
Checks whether a std::string::find()
result is compared with 0, and
suggests replacing with absl::StartsWith()
. This is both a readability and
performance issue.
string s = "...";
if (s.find("Hello World") == 0) { /* do something */ }
becomes
string s = "...";
if (absl::StartsWith(s, "Hello World")) { /* do something */ }