It is more efficient to provide a character instead of a string when searching for a single character. This has been fixed in various places.
This commit is contained in:
parent
8a45c3192b
commit
4a439b9308
|
@ -79,7 +79,7 @@ std::string AnalyzerInformation::getAnalyzerInfoFile(const std::string &buildDir
|
||||||
std::string filename = Path::fromNativeSeparators(buildDir);
|
std::string filename = Path::fromNativeSeparators(buildDir);
|
||||||
if (filename.back() != '/')
|
if (filename.back() != '/')
|
||||||
filename += '/';
|
filename += '/';
|
||||||
const std::string::size_type pos = sourcefile.rfind("/");
|
const std::string::size_type pos = sourcefile.rfind('/');
|
||||||
if (pos == std::string::npos)
|
if (pos == std::string::npos)
|
||||||
filename += sourcefile;
|
filename += sourcefile;
|
||||||
else
|
else
|
||||||
|
|
|
@ -66,7 +66,7 @@ void ImportProject::FileSettings::setDefines(std::string defs)
|
||||||
{
|
{
|
||||||
while (defs.find(";%(") != std::string::npos) {
|
while (defs.find(";%(") != std::string::npos) {
|
||||||
std::string::size_type pos1 = defs.find(";%(");
|
std::string::size_type pos1 = defs.find(";%(");
|
||||||
std::string::size_type pos2 = defs.find(";", pos1+1);
|
std::string::size_type pos2 = defs.find(';', pos1+1);
|
||||||
defs.erase(pos1, pos2 == std::string::npos ? pos2 : (pos2-pos1));
|
defs.erase(pos1, pos2 == std::string::npos ? pos2 : (pos2-pos1));
|
||||||
}
|
}
|
||||||
while (defs.find(";;") != std::string::npos)
|
while (defs.find(";;") != std::string::npos)
|
||||||
|
@ -96,7 +96,7 @@ static bool simplifyPathWithVariables(std::string &s, const std::map<std::string
|
||||||
std::set<std::string> expanded;
|
std::set<std::string> expanded;
|
||||||
std::string::size_type start = 0;
|
std::string::size_type start = 0;
|
||||||
while ((start = s.find("$(")) != std::string::npos) {
|
while ((start = s.find("$(")) != std::string::npos) {
|
||||||
std::string::size_type end = s.find(")",start);
|
std::string::size_type end = s.find(')',start);
|
||||||
if (end == std::string::npos)
|
if (end == std::string::npos)
|
||||||
break;
|
break;
|
||||||
const std::string &var = s.substr(start+2,end-start-2);
|
const std::string &var = s.substr(start+2,end-start-2);
|
||||||
|
@ -187,7 +187,7 @@ void ImportProject::importCompileCommands(std::istream &istr)
|
||||||
const std::string command = values["command"];
|
const std::string command = values["command"];
|
||||||
const std::string directory = Path::fromNativeSeparators(values["directory"]);
|
const std::string directory = Path::fromNativeSeparators(values["directory"]);
|
||||||
std::string::size_type pos = 0;
|
std::string::size_type pos = 0;
|
||||||
while (std::string::npos != (pos = command.find(" ",pos))) {
|
while (std::string::npos != (pos = command.find(' ',pos))) {
|
||||||
pos++;
|
pos++;
|
||||||
if (pos >= command.size())
|
if (pos >= command.size())
|
||||||
break;
|
break;
|
||||||
|
@ -236,7 +236,7 @@ static void loadVisualStudioProperties(const std::string &props, std::map<std::s
|
||||||
for (const tinyxml2::XMLElement *importGroup = node->FirstChildElement(); importGroup; importGroup = importGroup->NextSiblingElement()) {
|
for (const tinyxml2::XMLElement *importGroup = node->FirstChildElement(); importGroup; importGroup = importGroup->NextSiblingElement()) {
|
||||||
if (std::strcmp(importGroup->Name(), "Import") == 0 && importGroup->Attribute("Project")) {
|
if (std::strcmp(importGroup->Name(), "Import") == 0 && importGroup->Attribute("Project")) {
|
||||||
std::string loadprj = importGroup->Attribute("Project");
|
std::string loadprj = importGroup->Attribute("Project");
|
||||||
if (loadprj.find("$") == std::string::npos) {
|
if (loadprj.find('$') == std::string::npos) {
|
||||||
loadprj = Path::getPathFromFilename(filename) + loadprj;
|
loadprj = Path::getPathFromFilename(filename) + loadprj;
|
||||||
}
|
}
|
||||||
loadVisualStudioProperties(loadprj, variables, includePath, additionalIncludeDirectories);
|
loadVisualStudioProperties(loadprj, variables, includePath, additionalIncludeDirectories);
|
||||||
|
@ -294,7 +294,7 @@ void ImportProject::importSln(std::istream &istr, const std::string &path)
|
||||||
const std::string::size_type pos = line.find(".vcxproj");
|
const std::string::size_type pos = line.find(".vcxproj");
|
||||||
if (pos == std::string::npos)
|
if (pos == std::string::npos)
|
||||||
continue;
|
continue;
|
||||||
const std::string::size_type pos1 = line.rfind("\"",pos);
|
const std::string::size_type pos1 = line.rfind('\"',pos);
|
||||||
if (pos == std::string::npos)
|
if (pos == std::string::npos)
|
||||||
continue;
|
continue;
|
||||||
const std::string vcxproj(line.substr(pos1+1, pos-pos1+7));
|
const std::string vcxproj(line.substr(pos1+1, pos-pos1+7));
|
||||||
|
@ -383,7 +383,7 @@ static std::list<std::string> toStringList(const std::string &s)
|
||||||
std::list<std::string> ret;
|
std::list<std::string> ret;
|
||||||
std::string::size_type pos1 = 0;
|
std::string::size_type pos1 = 0;
|
||||||
std::string::size_type pos2;
|
std::string::size_type pos2;
|
||||||
while ((pos2 = s.find(";",pos1)) != std::string::npos) {
|
while ((pos2 = s.find(';',pos1)) != std::string::npos) {
|
||||||
ret.push_back(s.substr(pos1, pos2-pos1));
|
ret.push_back(s.substr(pos1, pos2-pos1));
|
||||||
pos1 = pos2 + 1;
|
pos1 = pos2 + 1;
|
||||||
if (pos1 >= s.size())
|
if (pos1 >= s.size())
|
||||||
|
|
|
@ -69,7 +69,7 @@ std::string Path::simplifyPath(std::string originalPath)
|
||||||
|
|
||||||
// Remove ./, .//, ./// etc. at the beginning
|
// Remove ./, .//, ./// etc. at the beginning
|
||||||
while (originalPath.compare(0,2,"./") == 0) { // remove "./././"
|
while (originalPath.compare(0,2,"./") == 0) { // remove "./././"
|
||||||
size_t toErase = originalPath.find_first_not_of("/",2);
|
const size_t toErase = originalPath.find_first_not_of('/', 2);
|
||||||
originalPath = originalPath.erase(0, toErase);
|
originalPath = originalPath.erase(0, toErase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -257,10 +257,10 @@ static std::string cfg(const std::vector<std::string> &configs, const std::strin
|
||||||
static bool isUndefined(const std::string &cfg, const std::set<std::string> &undefined)
|
static bool isUndefined(const std::string &cfg, const std::set<std::string> &undefined)
|
||||||
{
|
{
|
||||||
for (std::string::size_type pos1 = 0U; pos1 < cfg.size();) {
|
for (std::string::size_type pos1 = 0U; pos1 < cfg.size();) {
|
||||||
const std::string::size_type pos2 = cfg.find(";",pos1);
|
const std::string::size_type pos2 = cfg.find(';',pos1);
|
||||||
const std::string def = (pos2 == std::string::npos) ? cfg.substr(pos1) : cfg.substr(pos1, pos2 - pos1);
|
const std::string def = (pos2 == std::string::npos) ? cfg.substr(pos1) : cfg.substr(pos1, pos2 - pos1);
|
||||||
|
|
||||||
std::string::size_type eq = def.find("=");
|
std::string::size_type eq = def.find('=');
|
||||||
if (eq == std::string::npos && undefined.find(def) != undefined.end())
|
if (eq == std::string::npos && undefined.find(def) != undefined.end())
|
||||||
return true;
|
return true;
|
||||||
if (eq != std::string::npos && undefined.find(def.substr(0,eq)) != undefined.end() && def.substr(eq) != "=0")
|
if (eq != std::string::npos && undefined.find(def.substr(0,eq)) != undefined.end() && def.substr(eq) != "=0")
|
||||||
|
@ -449,9 +449,9 @@ void Preprocessor::preprocess(std::istream &srcCodeStream, std::string &processe
|
||||||
static void splitcfg(const std::string &cfg, std::list<std::string> &defines, const std::string &defaultValue)
|
static void splitcfg(const std::string &cfg, std::list<std::string> &defines, const std::string &defaultValue)
|
||||||
{
|
{
|
||||||
for (std::string::size_type defineStartPos = 0U; defineStartPos < cfg.size();) {
|
for (std::string::size_type defineStartPos = 0U; defineStartPos < cfg.size();) {
|
||||||
const std::string::size_type defineEndPos = cfg.find(";", defineStartPos);
|
const std::string::size_type defineEndPos = cfg.find(';', defineStartPos);
|
||||||
std::string def = (defineEndPos == std::string::npos) ? cfg.substr(defineStartPos) : cfg.substr(defineStartPos, defineEndPos - defineStartPos);
|
std::string def = (defineEndPos == std::string::npos) ? cfg.substr(defineStartPos) : cfg.substr(defineStartPos, defineEndPos - defineStartPos);
|
||||||
if (!defaultValue.empty() && def.find("=") == std::string::npos)
|
if (!defaultValue.empty() && def.find('=') == std::string::npos)
|
||||||
def += '=' + defaultValue;
|
def += '=' + defaultValue;
|
||||||
defines.push_back(def);
|
defines.push_back(def);
|
||||||
if (defineEndPos == std::string::npos)
|
if (defineEndPos == std::string::npos)
|
||||||
|
@ -480,7 +480,7 @@ static simplecpp::DUI createDUI(const Settings &_settings, const std::string &cf
|
||||||
if (s[pos] == ' ') {
|
if (s[pos] == ' ') {
|
||||||
s[pos] = '=';
|
s[pos] = '=';
|
||||||
} else {
|
} else {
|
||||||
s[s.find(")")+1] = '=';
|
s[s.find(')')+1] = '=';
|
||||||
}
|
}
|
||||||
dui.defines.push_back(s);
|
dui.defines.push_back(s);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue