Visitar URL original
It is more efficient to provide a character instead of as string when… · dummyunit/simplecpp@ada134a · GitHub
Skip to content

Commit ada134a

Browse files
committed
It is more efficient to provide a character instead of as string when searching for as single character. This has been fixed in various places.
1 parent d1c995c commit ada134a

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎simplecpp.cpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen
466466
}
467467
if (multiline || startsWith(lastLine(10),"# ")) {
468468
pos = 0;
469-
while ((pos = currentToken.find("\n",pos)) != std::string::npos) {
469+
while ((pos = currentToken.find('\n',pos)) != std::string::npos) {
470470
currentToken.erase(pos,1);
471471
++multiline;
472472
}
@@ -1646,7 +1646,7 @@ std::string simplifyPath(std::string path) {
16461646
// remove "xyz/../"
16471647
pos = 1U;
16481648
while ((pos = path.find("/../", pos)) != std::string::npos) {
1649-
const std::string::size_type pos1 = path.rfind("/", pos - 1U);
1649+
const std::string::size_type pos1 = path.rfind('/', pos - 1U);
16501650
if (pos1 == std::string::npos)
16511651
pos++;
16521652
else {
@@ -1683,7 +1683,7 @@ void simplifySizeof(simplecpp::TokenList &expr, const std::map<std::string, std:
16831683
for (simplecpp::Token *typeToken = tok1; typeToken != tok2; typeToken = typeToken->next) {
16841684
if ((typeToken->str == "unsigned" || typeToken->str == "signed") && typeToken->next->name)
16851685
continue;
1686-
if (typeToken->str == "*" && type.find("*") != std::string::npos)
1686+
if (typeToken->str == "*" && type.find('*') != std::string::npos)
16871687
continue;
16881688
if (!type.empty())
16891689
type += ' ';
@@ -1931,8 +1931,8 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
19311931
std::map<TokenString, Macro> macros;
19321932
for (std::list<std::string>::const_iterator it = dui.defines.begin(); it != dui.defines.end(); ++it) {
19331933
const std::string &macrostr = *it;
1934-
const std::string::size_type eq = macrostr.find("=");
1935-
const std::string::size_type par = macrostr.find("(");
1934+
const std::string::size_type eq = macrostr.find('=');
1935+
const std::string::size_type par = macrostr.find('(');
19361936
const std::string macroname = macrostr.substr(0, std::min(eq,par));
19371937
if (dui.undefined.find(macroname) != dui.undefined.end())
19381938
continue;

0 commit comments

Comments
 (0)