Optimize calls to std::string::find() and friends for a single char.
The character literal overload is more efficient. PiperOrigin-RevId: 348473483 Change-Id: Ia76efa5ee243f7a92b35f1fb81d4af864fca8372
This commit is contained in:
parent
743b347ccf
commit
373f458fb6
@ -838,11 +838,11 @@ StatusOr<std::vector<uint8>> CompileToHsaco(
|
||||
// Delete the first two lines, since they usually vary even when the rest of
|
||||
// the code is the same (but verify that they are what we expect).
|
||||
if (str.size() >= 13 && str.substr(0, 13) == "; ModuleID = ") {
|
||||
auto pos = str.find("\n");
|
||||
auto pos = str.find('\n');
|
||||
if (pos != std::string::npos) str = str.substr(pos + 1);
|
||||
}
|
||||
if (str.size() >= 18 && str.substr(0, 18) == "source_filename = ") {
|
||||
auto pos = str.find("\n");
|
||||
auto pos = str.find('\n');
|
||||
if (pos != std::string::npos) str = str.substr(pos + 1);
|
||||
}
|
||||
str += hlo_module_config.compilation_cache_key();
|
||||
|
||||
@ -2538,7 +2538,7 @@ string PrintName(const string& name, bool print_ids) {
|
||||
if (print_ids) {
|
||||
return name;
|
||||
} else {
|
||||
auto dot_position = name.find_first_of(".");
|
||||
auto dot_position = name.find_first_of('.');
|
||||
return name.substr(0, dot_position);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1210,7 +1210,7 @@ XLA_TEST_P(EinsumTest, SimpleEinsumTest) {
|
||||
.ValueOrDie(),
|
||||
&builder);
|
||||
auto config = std::get<2>(GetParam());
|
||||
if (config.find(",") == config.npos) {
|
||||
if (config.find(',') == config.npos) {
|
||||
Einsum(x, config);
|
||||
} else {
|
||||
Einsum(x, y, config);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user