small optimization
This commit is contained in:
@ -101,7 +101,7 @@ void CiteMe::add(const std::string &reference)
|
|||||||
if (logfile_flag == VERBOSE) logbuffer += "\n";
|
if (logfile_flag == VERBOSE) logbuffer += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t found = reference.find_first_of("\n");
|
std::size_t found = reference.find_first_of('\n');
|
||||||
std::string header = reference.substr(0,found+1);
|
std::string header = reference.substr(0,found+1);
|
||||||
if (screen_flag == VERBOSE) scrbuffer += "- " + reference;
|
if (screen_flag == VERBOSE) scrbuffer += "- " + reference;
|
||||||
if (screen_flag == TERSE) scrbuffer += "- " + header;
|
if (screen_flag == TERSE) scrbuffer += "- " + header;
|
||||||
|
|||||||
@ -1257,7 +1257,7 @@ void Input::shell()
|
|||||||
#else
|
#else
|
||||||
if (arg[i]) {
|
if (arg[i]) {
|
||||||
std::string vardef(arg[i]);
|
std::string vardef(arg[i]);
|
||||||
auto found = vardef.find_first_of("=");
|
auto found = vardef.find_first_of('=');
|
||||||
if (found == std::string::npos) {
|
if (found == std::string::npos) {
|
||||||
rv = setenv(vardef.c_str(),"",1);
|
rv = setenv(vardef.c_str(),"",1);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -174,7 +174,7 @@ void Universe::add_world(char *str)
|
|||||||
if (part.find_first_not_of("0123456789x") != std::string::npos) valid = false;
|
if (part.find_first_not_of("0123456789x") != std::string::npos) valid = false;
|
||||||
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
std::size_t found = part.find_first_of("x");
|
std::size_t found = part.find_first_of('x');
|
||||||
|
|
||||||
// 'x' may not be the first or last character
|
// 'x' may not be the first or last character
|
||||||
|
|
||||||
|
|||||||
@ -502,7 +502,7 @@ void utils::bounds(const char *file, int line, const std::string &str,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
found = str.find_first_of("*");
|
found = str.find_first_of('*');
|
||||||
if (found == std::string::npos) { // contains no '*'
|
if (found == std::string::npos) { // contains no '*'
|
||||||
nlo = nhi = strtol(str.c_str(), nullptr, 10);
|
nlo = nhi = strtol(str.c_str(), nullptr, 10);
|
||||||
} else if (str.size() == 1) { // is only '*'
|
} else if (str.size() == 1) { // is only '*'
|
||||||
@ -727,7 +727,7 @@ std::string utils::trim(const std::string &line)
|
|||||||
|
|
||||||
std::string utils::trim_comment(const std::string &line)
|
std::string utils::trim_comment(const std::string &line)
|
||||||
{
|
{
|
||||||
auto end = line.find_first_of("#");
|
auto end = line.find_first_of('#');
|
||||||
if (end != std::string::npos) { return line.substr(0, end); }
|
if (end != std::string::npos) { return line.substr(0, end); }
|
||||||
return std::string(line);
|
return std::string(line);
|
||||||
}
|
}
|
||||||
@ -1030,7 +1030,7 @@ std::string utils::path_basename(const std::string &path)
|
|||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
size_t start = path.find_last_of("/\\");
|
size_t start = path.find_last_of("/\\");
|
||||||
#else
|
#else
|
||||||
size_t start = path.find_last_of("/");
|
size_t start = path.find_last_of('/');
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (start == std::string::npos) {
|
if (start == std::string::npos) {
|
||||||
@ -1051,7 +1051,7 @@ std::string utils::path_dirname(const std::string &path)
|
|||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
size_t start = path.find_last_of("/\\");
|
size_t start = path.find_last_of("/\\");
|
||||||
#else
|
#else
|
||||||
size_t start = path.find_last_of("/");
|
size_t start = path.find_last_of('/');
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (start == std::string::npos) return ".";
|
if (start == std::string::npos) return ".";
|
||||||
|
|||||||
Reference in New Issue
Block a user