mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2025-01-03 05:00:15 +00:00
Prefer find(char) over find(const char *)
The former can be faster. Found via clang-tidy.
This commit is contained in:
parent
25b49e1a2e
commit
e29548178b
12
src/s3fs.cpp
12
src/s3fs.cpp
@ -2896,7 +2896,7 @@ static bool parse_xattr_keyval(const std::string& xattrpair, string& key, PXATTR
|
|||||||
// parse key and value
|
// parse key and value
|
||||||
size_t pos;
|
size_t pos;
|
||||||
string tmpval;
|
string tmpval;
|
||||||
if(string::npos == (pos = xattrpair.find_first_of(":"))){
|
if(string::npos == (pos = xattrpair.find_first_of(':'))){
|
||||||
S3FS_PRN_ERR("one of xattr pair(%s) is wrong format.", xattrpair.c_str());
|
S3FS_PRN_ERR("one of xattr pair(%s) is wrong format.", xattrpair.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2927,8 +2927,8 @@ static size_t parse_xattrs(const std::string& strxattrs, xattrs_t& xattrs)
|
|||||||
{
|
{
|
||||||
size_t startpos;
|
size_t startpos;
|
||||||
size_t endpos = string::npos;
|
size_t endpos = string::npos;
|
||||||
if(string::npos != (startpos = jsonxattrs.find_first_of("{"))){
|
if(string::npos != (startpos = jsonxattrs.find_first_of('{'))){
|
||||||
endpos = jsonxattrs.find_last_of("}");
|
endpos = jsonxattrs.find_last_of('}');
|
||||||
}
|
}
|
||||||
if(startpos == string::npos || endpos == string::npos || endpos <= startpos){
|
if(startpos == string::npos || endpos == string::npos || endpos <= startpos){
|
||||||
S3FS_PRN_WARN("xattr header(%s) is not json format.", jsonxattrs.c_str());
|
S3FS_PRN_WARN("xattr header(%s) is not json format.", jsonxattrs.c_str());
|
||||||
@ -2938,7 +2938,7 @@ static size_t parse_xattrs(const std::string& strxattrs, xattrs_t& xattrs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// parse each key:val
|
// parse each key:val
|
||||||
for(size_t pair_nextpos = restxattrs.find_first_of(","); 0 < restxattrs.length(); restxattrs = (pair_nextpos != string::npos ? restxattrs.substr(pair_nextpos + 1) : string("")), pair_nextpos = restxattrs.find_first_of(",")){
|
for(size_t pair_nextpos = restxattrs.find_first_of(','); 0 < restxattrs.length(); restxattrs = (pair_nextpos != string::npos ? restxattrs.substr(pair_nextpos + 1) : string("")), pair_nextpos = restxattrs.find_first_of(',')){
|
||||||
string pair = pair_nextpos != string::npos ? restxattrs.substr(0, pair_nextpos) : restxattrs;
|
string pair = pair_nextpos != string::npos ? restxattrs.substr(0, pair_nextpos) : restxattrs;
|
||||||
string key = "";
|
string key = "";
|
||||||
PXATTRVAL pval = NULL;
|
PXATTRVAL pval = NULL;
|
||||||
@ -3862,7 +3862,7 @@ static int parse_passwd_file(bucketkvmap_t& resmap)
|
|||||||
S3FS_PRN_EXIT("invalid line in passwd file, found whitespace character.");
|
S3FS_PRN_EXIT("invalid line in passwd file, found whitespace character.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(0 == line.find_first_of("[")){
|
if(0 == line.find_first_of('[')){
|
||||||
S3FS_PRN_EXIT("invalid line in passwd file, found a bracket \"[\" character.");
|
S3FS_PRN_EXIT("invalid line in passwd file, found a bracket \"[\" character.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -4953,7 +4953,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
// get program name - emulate basename
|
// get program name - emulate basename
|
||||||
program_name.assign(argv[0]);
|
program_name.assign(argv[0]);
|
||||||
size_t found = program_name.find_last_of("/");
|
size_t found = program_name.find_last_of('/');
|
||||||
if(found != string::npos){
|
if(found != string::npos){
|
||||||
program_name.replace(0, found+1, "");
|
program_name.replace(0, found+1, "");
|
||||||
}
|
}
|
||||||
|
@ -283,7 +283,7 @@ bool S3ObjList::MakeHierarchizedList(s3obj_list_t& list, bool haveSlash)
|
|||||||
h_map[strtmp] = true;
|
h_map[strtmp] = true;
|
||||||
|
|
||||||
// check hierarchized directory
|
// check hierarchized directory
|
||||||
for(string::size_type pos = strtmp.find_last_of("/"); string::npos != pos; pos = strtmp.find_last_of("/")){
|
for(string::size_type pos = strtmp.find_last_of('/'); string::npos != pos; pos = strtmp.find_last_of('/')){
|
||||||
strtmp = strtmp.substr(0, pos);
|
strtmp = strtmp.substr(0, pos);
|
||||||
if(0 == strtmp.length() || "/" == strtmp){
|
if(0 == strtmp.length() || "/" == strtmp){
|
||||||
break;
|
break;
|
||||||
@ -822,7 +822,7 @@ mode_t get_mode(headers_t& meta, const char* path, bool checkdir, bool forcedir)
|
|||||||
if(meta.end() != (iter = meta.find("Content-Type"))){
|
if(meta.end() != (iter = meta.find("Content-Type"))){
|
||||||
string strConType = (*iter).second;
|
string strConType = (*iter).second;
|
||||||
// Leave just the mime type, remove any optional parameters (eg charset)
|
// Leave just the mime type, remove any optional parameters (eg charset)
|
||||||
string::size_type pos = strConType.find(";");
|
string::size_type pos = strConType.find(';');
|
||||||
if(string::npos != pos){
|
if(string::npos != pos){
|
||||||
strConType = strConType.substr(0, pos);
|
strConType = strConType.substr(0, pos);
|
||||||
}
|
}
|
||||||
|
@ -210,15 +210,15 @@ bool takeout_str_dquart(string& str)
|
|||||||
size_t pos;
|
size_t pos;
|
||||||
|
|
||||||
// '"' for start
|
// '"' for start
|
||||||
if(string::npos != (pos = str.find_first_of("\""))){
|
if(string::npos != (pos = str.find_first_of('\"'))){
|
||||||
str = str.substr(pos + 1);
|
str = str.substr(pos + 1);
|
||||||
|
|
||||||
// '"' for end
|
// '"' for end
|
||||||
if(string::npos == (pos = str.find_last_of("\""))){
|
if(string::npos == (pos = str.find_last_of('\"'))){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
str = str.substr(0, pos);
|
str = str.substr(0, pos);
|
||||||
if(string::npos != str.find_first_of("\"")){
|
if(string::npos != str.find_first_of('\"')){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user