Use std::string/string_view versions of starts_with/ends_with where appropriate

The util:: versions of these methods remain as a thin wrapper around them so
they can be used with const char* arguments. Otherwise callers have to manually
make string_view objects from the input.
s Please enter the commit message for your changes. Lines starting
This commit is contained in:
Tim Wojtulewicz 2025-07-11 11:50:12 -07:00
parent 6218643347
commit a1d121e5aa
17 changed files with 30 additions and 55 deletions

View file

@ -91,10 +91,10 @@ TraversalCode Scope::Traverse(TraversalCallback* cb) const {
const IDPtr& lookup_ID(const char* name, const char* curr_module, bool no_global, bool same_module_only,
bool check_export) {
bool explicit_global = zeek::util::starts_with(name, "::");
bool explicit_global = std::string_view{name}.starts_with("::");
static std::string global_prefix = util::fmt("%s::", GLOBAL_MODULE_NAME);
if ( zeek::util::starts_with(name, global_prefix) )
if ( std::string_view{name}.starts_with(global_prefix) )
reporter->Error("Using GLOBAL:: as a prefix is invalid. Use :: instead (%s)", name);
std::string fullname = make_full_var_name(curr_module, name);