diff --git a/src/util/infix.h b/src/util/infix.h index 0ff47c646c1..6122c0e35bb 100644 --- a/src/util/infix.h +++ b/src/util/infix.h @@ -12,12 +12,9 @@ Author: Chris Smowton, chris.smowton@diffblue.com #ifndef CPROVER_UTIL_INFIX_H #define CPROVER_UTIL_INFIX_H -#include +#include -inline bool has_infix( - const std::string &s, - const std::string &infix, - size_t offset) +inline bool has_infix(std::string_view s, std::string_view infix, size_t offset) { return s.compare(offset, infix.size(), infix)==0; } diff --git a/src/util/prefix.h b/src/util/prefix.h index b94c1cd93d2..3d49f1949c1 100644 --- a/src/util/prefix.h +++ b/src/util/prefix.h @@ -10,11 +10,11 @@ Author: Daniel Kroening, kroening@kroening.com #ifndef CPROVER_UTIL_PREFIX_H #define CPROVER_UTIL_PREFIX_H -#include +#include -// C++20 will have std::string::starts_with +// C++20 will have std::string_view::starts_with -inline bool has_prefix(const std::string &s, const std::string &prefix) +inline bool has_prefix(std::string_view s, std::string_view prefix) { return s.compare(0, prefix.size(), prefix)==0; } diff --git a/src/util/suffix.h b/src/util/suffix.h index 4ec273d89f9..10fa8f30cdf 100644 --- a/src/util/suffix.h +++ b/src/util/suffix.h @@ -12,9 +12,9 @@ Author: Daniel Kroening, kroening@kroening.com #include -// C++20 will have std::string::ends_with +// C++20 will have std::string_view::ends_with -inline bool has_suffix(const std::string &s, const std::string &suffix) +inline bool has_suffix(std::string_view s, std::string_view suffix) { if(suffix.size()>s.size()) return false;