mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 18:18:19 +00:00
util: reserve space in normalize_path()
Pessimistic reservations to ensure that it does not need to be reallocated.
This commit is contained in:
parent
5c0c336c6b
commit
53c4e30024
1 changed files with 2 additions and 0 deletions
|
@ -1557,11 +1557,13 @@ string normalize_path(const std::string_view path)
|
||||||
size_t n;
|
size_t n;
|
||||||
vector<string> components, final_components;
|
vector<string> components, final_components;
|
||||||
string new_path;
|
string new_path;
|
||||||
|
new_path.reserve(path.size());
|
||||||
|
|
||||||
if ( !path.empty() && path[0] == '/' )
|
if ( !path.empty() && path[0] == '/' )
|
||||||
new_path = "/";
|
new_path = "/";
|
||||||
|
|
||||||
tokenize_string(path, "/", &components);
|
tokenize_string(path, "/", &components);
|
||||||
|
final_components.reserve(components.size());
|
||||||
|
|
||||||
vector<string>::const_iterator it;
|
vector<string>::const_iterator it;
|
||||||
for ( it = components.begin(); it != components.end(); ++it )
|
for ( it = components.begin(); it != components.end(); ++it )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue