mirror of
https://github.com/zeek/zeek.git
synced 2025-10-13 20:18:20 +00:00
util: pass string_view to without_bropath_component()
This commit is contained in:
parent
0548e1255f
commit
98241bbc60
2 changed files with 7 additions and 6 deletions
11
src/util.cc
11
src/util.cc
|
@ -1669,7 +1669,7 @@ string normalize_path(std::string_view path)
|
||||||
return new_path;
|
return new_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
string without_bropath_component(const string& path)
|
string without_bropath_component(std::string_view path)
|
||||||
{
|
{
|
||||||
string rval = normalize_path(path);
|
string rval = normalize_path(path);
|
||||||
|
|
||||||
|
@ -1683,13 +1683,14 @@ string without_bropath_component(const string& path)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Found the containing directory.
|
// Found the containing directory.
|
||||||
rval.erase(0, common.size());
|
std::string_view v(rval);
|
||||||
|
v.remove_prefix(common.size());
|
||||||
|
|
||||||
// Remove leading path separators.
|
// Remove leading path separators.
|
||||||
while ( rval.size() && rval[0] == '/' )
|
while ( !v.empty() && v.front() == '/' )
|
||||||
rval.erase(0, 1);
|
v.remove_prefix(1);
|
||||||
|
|
||||||
return rval;
|
return std::string(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rval;
|
return rval;
|
||||||
|
|
|
@ -353,7 +353,7 @@ std::string normalize_path(std::string_view path);
|
||||||
* @param path A file/directory path that may be within a ZEEKPATH component.
|
* @param path A file/directory path that may be within a ZEEKPATH component.
|
||||||
* @return *path* minus the common ZEEKPATH component (if any) removed.
|
* @return *path* minus the common ZEEKPATH component (if any) removed.
|
||||||
*/
|
*/
|
||||||
std::string without_bropath_component(const std::string& path);
|
std::string without_bropath_component(std::string_view path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Locate a file within a given search path.
|
* Locate a file within a given search path.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue