mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 00:58:19 +00:00
util: pass std::string_view to normalize_path()
Reduce overhead in some callers.
This commit is contained in:
parent
f1566bda14
commit
0589f295fa
2 changed files with 3 additions and 3 deletions
|
@ -1552,13 +1552,13 @@ TEST_CASE("util normalize_path")
|
|||
CHECK(normalize_path("zeek/../..") == "..");
|
||||
}
|
||||
|
||||
string normalize_path(const string& path)
|
||||
string normalize_path(const std::string_view path)
|
||||
{
|
||||
size_t n;
|
||||
vector<string> components, final_components;
|
||||
string new_path;
|
||||
|
||||
if ( path[0] == '/' )
|
||||
if ( !path.empty() && path[0] == '/' )
|
||||
new_path = "/";
|
||||
|
||||
tokenize_string(path, "/", &components);
|
||||
|
|
|
@ -344,7 +344,7 @@ std::string flatten_script_name(const std::string& name,
|
|||
* @param path A filesystem path.
|
||||
* @return A canonical/shortened version of \a path.
|
||||
*/
|
||||
std::string normalize_path(const std::string& path);
|
||||
std::string normalize_path(std::string_view path);
|
||||
|
||||
/**
|
||||
* Strip the ZEEKPATH component from a path.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue