Optimize calls to std::string::find() and friends for a single char.

The character literal overload is more efficient.

PiperOrigin-RevId: 347827459
Change-Id: I91ab1c5ea699886b6c15ad5016338063e0c98f40
This commit is contained in:
Chris Kennelly 2020-12-16 08:30:14 -08:00 committed by Copybara-Service
parent 4763959227
commit 324ab5974c

View File

@ -98,7 +98,7 @@ static absl::Status ParseIpAndMask(const std::string& ip_and_mask,
}
std::string mask_or_cidr = ip_and_mask_split[1];
const bool has_dot = mask_or_cidr.find(".") == absl::string_view::npos;
const bool has_dot = mask_or_cidr.find('.') == absl::string_view::npos;
if (has_dot) { // mask_or_cidr is cidr
bool res = absl::SimpleAtoi<uint32_t>(mask_or_cidr, cidr);
if (!res || !*cidr) {