small optimization

This commit is contained in:
Axel Kohlmeyer
2021-09-15 15:14:52 -04:00
parent f01681eae7
commit 1fdba7280e
4 changed files with 7 additions and 7 deletions

View File

@ -101,7 +101,7 @@ void CiteMe::add(const std::string &reference)
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);
if (screen_flag == VERBOSE) scrbuffer += "- " + reference;
if (screen_flag == TERSE) scrbuffer += "- " + header;

View File

@ -1257,7 +1257,7 @@ void Input::shell()
#else
if (arg[i]) {
std::string vardef(arg[i]);
auto found = vardef.find_first_of("=");
auto found = vardef.find_first_of('=');
if (found == std::string::npos) {
rv = setenv(vardef.c_str(),"",1);
} else {

View File

@ -174,7 +174,7 @@ void Universe::add_world(char *str)
if (part.find_first_not_of("0123456789x") != std::string::npos) valid = false;
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

View File

@ -502,7 +502,7 @@ void utils::bounds(const char *file, int line, const std::string &str,
return;
}
found = str.find_first_of("*");
found = str.find_first_of('*');
if (found == std::string::npos) { // contains no '*'
nlo = nhi = strtol(str.c_str(), nullptr, 10);
} 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)
{
auto end = line.find_first_of("#");
auto end = line.find_first_of('#');
if (end != std::string::npos) { return line.substr(0, end); }
return std::string(line);
}
@ -1030,7 +1030,7 @@ std::string utils::path_basename(const std::string &path)
#if defined(_WIN32)
size_t start = path.find_last_of("/\\");
#else
size_t start = path.find_last_of("/");
size_t start = path.find_last_of('/');
#endif
if (start == std::string::npos) {
@ -1051,7 +1051,7 @@ std::string utils::path_dirname(const std::string &path)
#if defined(_WIN32)
size_t start = path.find_last_of("/\\");
#else
size_t start = path.find_last_of("/");
size_t start = path.find_last_of('/');
#endif
if (start == std::string::npos) return ".";