mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 16:48:19 +00:00
util: pass std::string_view to tokenize_string()
This saves some overhead because some callers pass a plain C string here which needed to be copied to a temporary std::string.
This commit is contained in:
parent
e068ad8a53
commit
f1566bda14
2 changed files with 4 additions and 3 deletions
|
@ -1501,7 +1501,7 @@ TEST_CASE("util tokenize_string")
|
|||
CHECK(v2.size() == 1);
|
||||
}
|
||||
|
||||
vector<string>* tokenize_string(const string &input, const string& delim,
|
||||
vector<string>* tokenize_string(const std::string_view input, const std::string_view delim,
|
||||
vector<string>* rval, int limit)
|
||||
{
|
||||
if ( ! rval )
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <cstdint>
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
|
@ -145,8 +146,8 @@ inline std::string get_escaped_string(const std::string& str, bool escape_all)
|
|||
return get_escaped_string(str.data(), str.length(), escape_all);
|
||||
}
|
||||
|
||||
std::vector<std::string>* tokenize_string(const std::string &input,
|
||||
const std::string& delim,
|
||||
std::vector<std::string>* tokenize_string(std::string_view input,
|
||||
std::string_view delim,
|
||||
std::vector<std::string>* rval = 0, int limit = 0);
|
||||
|
||||
extern char* copy_string(const char* s);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue