3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-11-23 14:11:28 +00:00

Make IdString::contains take std::string_view so we avoid a strlen when the parameter is a string constant

This commit is contained in:
Robert O'Callahan 2025-10-16 04:05:56 +00:00 committed by Emil J. Tywoniak
parent 2319d82efb
commit 32641bbf93

View file

@ -416,8 +416,8 @@ struct RTLIL::IdString
return compare(sz - suffix.size(), suffix.size(), suffix.data()) == 0; return compare(sz - suffix.size(), suffix.size(), suffix.data()) == 0;
} }
bool contains(const char* str) const { bool contains(std::string_view s) const {
return strstr(c_str(), str); return std::string_view(c_str()).find(s) != std::string::npos;
} }
size_t size() const { size_t size() const {