ENH: perfomance: seeking of one char is more efficiently
This commit is contained in:
parent
a1081f961c
commit
d41d091c07
|
@ -143,11 +143,11 @@ unsigned int CppCheck::processFile(const std::string& filename, const std::strin
|
||||||
|
|
||||||
if (!_settings.plistOutput.empty()) {
|
if (!_settings.plistOutput.empty()) {
|
||||||
std::string filename2;
|
std::string filename2;
|
||||||
if (filename.find("/") != std::string::npos)
|
if (filename.find('/') != std::string::npos)
|
||||||
filename2 = filename.substr(filename.rfind("/") + 1);
|
filename2 = filename.substr(filename.rfind('/') + 1);
|
||||||
else
|
else
|
||||||
filename2 = filename;
|
filename2 = filename;
|
||||||
filename2 = _settings.plistOutput + filename2.substr(0, filename2.find(".")) + ".plist";
|
filename2 = _settings.plistOutput + filename2.substr(0, filename2.find('.')) + ".plist";
|
||||||
plistFile.open(filename2);
|
plistFile.open(filename2);
|
||||||
plistFile << ErrorLogger::plistHeader(version(), files);
|
plistFile << ErrorLogger::plistHeader(version(), files);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ static std::string builddir(std::string filename)
|
||||||
|
|
||||||
static std::string objfile(std::string cppfile)
|
static std::string objfile(std::string cppfile)
|
||||||
{
|
{
|
||||||
cppfile.erase(cppfile.rfind("."));
|
cppfile.erase(cppfile.rfind('.'));
|
||||||
return builddir(cppfile + ".o");
|
return builddir(cppfile + ".o");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,15 +50,15 @@ static void getDeps(const std::string &filename, std::vector<std::string> &depfi
|
||||||
std::ifstream f(filename.c_str());
|
std::ifstream f(filename.c_str());
|
||||||
if (! f.is_open()) {
|
if (! f.is_open()) {
|
||||||
if (filename.compare(0, 4, "cli/") == 0 || filename.compare(0, 5, "test/") == 0)
|
if (filename.compare(0, 4, "cli/") == 0 || filename.compare(0, 5, "test/") == 0)
|
||||||
getDeps("lib" + filename.substr(filename.find("/")), depfiles);
|
getDeps("lib" + filename.substr(filename.find('/')), depfiles);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (filename.find(".c") == std::string::npos)
|
if (filename.find(".c") == std::string::npos)
|
||||||
depfiles.push_back(filename);
|
depfiles.push_back(filename);
|
||||||
|
|
||||||
std::string path(filename);
|
std::string path(filename);
|
||||||
if (path.find("/") != std::string::npos)
|
if (path.find('/') != std::string::npos)
|
||||||
path.erase(1 + path.rfind("/"));
|
path.erase(1 + path.rfind('/'));
|
||||||
|
|
||||||
std::string line;
|
std::string line;
|
||||||
while (std::getline(f, line)) {
|
while (std::getline(f, line)) {
|
||||||
|
@ -67,7 +67,7 @@ static void getDeps(const std::string &filename, std::vector<std::string> &depfi
|
||||||
continue;
|
continue;
|
||||||
pos1 += 10;
|
pos1 += 10;
|
||||||
|
|
||||||
std::string::size_type pos2 = line.find("\"", pos1);
|
std::string::size_type pos2 = line.find('\"', pos1);
|
||||||
std::string hfile(path + line.substr(pos1, pos2 - pos1));
|
std::string hfile(path + line.substr(pos1, pos2 - pos1));
|
||||||
if (hfile.find("/../") != std::string::npos) // TODO: Ugly fix
|
if (hfile.find("/../") != std::string::npos) // TODO: Ugly fix
|
||||||
hfile.erase(0, 4 + hfile.find("/../"));
|
hfile.erase(0, 4 + hfile.find("/../"));
|
||||||
|
|
Loading…
Reference in New Issue