Skip to content

Commit

Permalink
Optimize calls to std::string::find() and friends for a single char. (#…
Browse files Browse the repository at this point in the history
…598)

The character literal overload is more efficient.

Signed-off-by: Yan Avlasov <yavlasov@google.com>
  • Loading branch information
yanavlasov authored Dec 16, 2020
1 parent 3f9d6c2 commit 88d3bf4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions source/common/utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ Utility::mapCountersFromStore(const Envoy::Stats::Store& store,

size_t Utility::findPortSeparator(absl::string_view hostname) {
if (hostname.size() > 0 && hostname[0] == '[') {
return hostname.find(":", hostname.find(']'));
return hostname.find(':', hostname.find(']'));
}
return hostname.rfind(":");
return hostname.rfind(':');
}

Envoy::Network::DnsLookupFamily
Expand Down

0 comments on commit 88d3bf4

Please sign in to comment.