mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 01:58:20 +00:00
util: optimize the normal_path() common case
Speeds up Zeek startup by 2%.
This commit is contained in:
parent
98241bbc60
commit
95e646fca7
1 changed files with 9 additions and 0 deletions
|
@ -1612,6 +1612,15 @@ TEST_CASE("util normalize_path")
|
|||
|
||||
string normalize_path(std::string_view path)
|
||||
{
|
||||
if ( path.find("/.") == std::string_view::npos &&
|
||||
path.find("//") == std::string_view::npos )
|
||||
{
|
||||
// no need to normalize anything
|
||||
if ( path.size() > 1 && path.back() == '/' )
|
||||
path.remove_suffix(1);
|
||||
return std::string(path);
|
||||
}
|
||||
|
||||
size_t n;
|
||||
vector<std::string_view> final_components;
|
||||
string new_path;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue