mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 08:08:19 +00:00
Use single-character version of string find() (performance-faster-string-find)
This commit is contained in:
parent
95d2af4501
commit
c32566420a
8 changed files with 10 additions and 10 deletions
|
@ -402,7 +402,7 @@ void HTTP_Entity::SubmitHeader(mime::MIME_Header* h)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t p = byte_range.find("/");
|
size_t p = byte_range.find('/');
|
||||||
if ( p == string::npos )
|
if ( p == string::npos )
|
||||||
{
|
{
|
||||||
http_message->Weird("HTTP_content_range_cannot_parse");
|
http_message->Weird("HTTP_content_range_cannot_parse");
|
||||||
|
@ -412,7 +412,7 @@ void HTTP_Entity::SubmitHeader(mime::MIME_Header* h)
|
||||||
string byte_range_resp_spec = byte_range.substr(0, p);
|
string byte_range_resp_spec = byte_range.substr(0, p);
|
||||||
string instance_length_str = byte_range.substr(p + 1);
|
string instance_length_str = byte_range.substr(p + 1);
|
||||||
|
|
||||||
p = byte_range_resp_spec.find("-");
|
p = byte_range_resp_spec.find('-');
|
||||||
if ( p == string::npos )
|
if ( p == string::npos )
|
||||||
{
|
{
|
||||||
http_message->Weird("HTTP_content_range_cannot_parse");
|
http_message->Weird("HTTP_content_range_cannot_parse");
|
||||||
|
|
|
@ -34,7 +34,7 @@ void IRC_Analyzer::Done()
|
||||||
|
|
||||||
inline void IRC_Analyzer::SkipLeadingWhitespace(string& str)
|
inline void IRC_Analyzer::SkipLeadingWhitespace(string& str)
|
||||||
{
|
{
|
||||||
const auto first_char = str.find_first_not_of(" ");
|
const auto first_char = str.find_first_not_of(' ');
|
||||||
if ( first_char == string::npos )
|
if ( first_char == string::npos )
|
||||||
str = "";
|
str = "";
|
||||||
else
|
else
|
||||||
|
|
|
@ -13,7 +13,7 @@ refine connection XMPP_Conn += {
|
||||||
string token = std_str(name);
|
string token = std_str(name);
|
||||||
// Result will either be text after ":" or original string; this discards the namespace
|
// Result will either be text after ":" or original string; this discards the namespace
|
||||||
string token_no_ns = std_str(name);
|
string token_no_ns = std_str(name);
|
||||||
auto offset = token_no_ns.find(":");
|
auto offset = token_no_ns.find(':');
|
||||||
if ( offset != std::string::npos && token_no_ns.length() > offset + 1 )
|
if ( offset != std::string::npos && token_no_ns.length() > offset + 1 )
|
||||||
token_no_ns = token_no_ns.substr(offset + 1);
|
token_no_ns = token_no_ns.substr(offset + 1);
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ bool Ascii::OpenFile()
|
||||||
if ( fname.front() != '/' && ! path_prefix.empty() )
|
if ( fname.front() != '/' && ! path_prefix.empty() )
|
||||||
{
|
{
|
||||||
string path = path_prefix;
|
string path = path_prefix;
|
||||||
std::size_t last = path.find_last_not_of("/");
|
std::size_t last = path.find_last_not_of('/');
|
||||||
|
|
||||||
if ( last == string::npos ) // Nothing but slashes -- weird but ok...
|
if ( last == string::npos ) // Nothing but slashes -- weird but ok...
|
||||||
path = "/";
|
path = "/";
|
||||||
|
|
|
@ -111,7 +111,7 @@ bool Binary::DoInit(const ReaderInfo& info, int num_fields,
|
||||||
if ( fname.front() != '/' && ! path_prefix.empty() )
|
if ( fname.front() != '/' && ! path_prefix.empty() )
|
||||||
{
|
{
|
||||||
string path = path_prefix;
|
string path = path_prefix;
|
||||||
std::size_t last = path.find_last_not_of("/");
|
std::size_t last = path.find_last_not_of('/');
|
||||||
|
|
||||||
if ( last == string::npos ) // Nothing but slashes -- weird but ok...
|
if ( last == string::npos ) // Nothing but slashes -- weird but ok...
|
||||||
path = "/";
|
path = "/";
|
||||||
|
|
|
@ -210,7 +210,7 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p
|
||||||
{
|
{
|
||||||
const char *text = (const char*) sqlite3_column_text(st, pos);
|
const char *text = (const char*) sqlite3_column_text(st, pos);
|
||||||
string s(text, sqlite3_column_bytes(st, pos));
|
string s(text, sqlite3_column_bytes(st, pos));
|
||||||
int pos = s.find("/");
|
int pos = s.find('/');
|
||||||
int width = atoi(s.substr(pos+1).c_str());
|
int width = atoi(s.substr(pos+1).c_str());
|
||||||
string addr = s.substr(0, pos);
|
string addr = s.substr(0, pos);
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ void Manager::SearchDynamicPlugins(const std::string& dir)
|
||||||
if ( dir.empty() )
|
if ( dir.empty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( dir.find(":") != string::npos )
|
if ( dir.find(':') != string::npos )
|
||||||
{
|
{
|
||||||
// Split at ":".
|
// Split at ":".
|
||||||
std::stringstream s(dir);
|
std::stringstream s(dir);
|
||||||
|
@ -492,7 +492,7 @@ Plugin* Manager::LookupPluginByPath(std::string_view _path)
|
||||||
if ( i != plugins_by_path.end() )
|
if ( i != plugins_by_path.end() )
|
||||||
return i->second;
|
return i->second;
|
||||||
|
|
||||||
auto j = path.rfind("/");
|
auto j = path.rfind('/');
|
||||||
|
|
||||||
if ( j == std::string::npos )
|
if ( j == std::string::npos )
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -300,7 +300,7 @@ threading::Value* Ascii::ParseValue(const string& s, const string& name, TypeTag
|
||||||
case TYPE_SUBNET:
|
case TYPE_SUBNET:
|
||||||
{
|
{
|
||||||
string unescaped = strstrip(get_unescaped_string(s));
|
string unescaped = strstrip(get_unescaped_string(s));
|
||||||
size_t pos = unescaped.find("/");
|
size_t pos = unescaped.find('/');
|
||||||
if ( pos == unescaped.npos )
|
if ( pos == unescaped.npos )
|
||||||
{
|
{
|
||||||
GetThread()->Warning(GetThread()->Fmt("Invalid value for subnet: %s", start));
|
GetThread()->Warning(GetThread()->Fmt("Invalid value for subnet: %s", start));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue