Refactorizations:
- use std::string::pop_back() and std::string::back() - pass argument as const std::string& - Moved iterator into for loop head
This commit is contained in:
parent
7197456c23
commit
d665641a76
|
@ -71,8 +71,8 @@ void ImportProject::FileSettings::setDefines(std::string defs)
|
|||
}
|
||||
while (defs.find(";;") != std::string::npos)
|
||||
defs.erase(defs.find(";;"),1);
|
||||
if (!defs.empty() && defs[defs.size()-1U] == ';')
|
||||
defs.erase(defs.size()-1U);
|
||||
if (!defs.empty() && defs.back() == ';')
|
||||
defs.pop_back();
|
||||
bool eq = false;
|
||||
for (std::size_t pos = 0; pos < defs.size(); ++pos) {
|
||||
if (defs[pos] == '(' || defs[pos] == '=')
|
||||
|
@ -124,14 +124,14 @@ void ImportProject::FileSettings::setIncludePaths(const std::string &basepath, c
|
|||
continue;
|
||||
std::string s(Path::fromNativeSeparators(*it));
|
||||
if (s[0] == '/' || (s.size() > 1U && s.compare(1,2,":/") == 0)) {
|
||||
if (s[s.size()-1U] != '/')
|
||||
if (s.back() != '/')
|
||||
s += '/';
|
||||
I.push_back(s);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (s[s.size()-1U] == '/') // this is a temporary hack, simplifyPath can crash if path ends with '/'
|
||||
s.erase(s.size() - 1U);
|
||||
if (s.back() == '/') // this is a temporary hack, simplifyPath can crash if path ends with '/'
|
||||
s.pop_back();
|
||||
|
||||
if (s.find("$(")==std::string::npos) {
|
||||
s = Path::simplifyPath(basepath + s);
|
||||
|
@ -155,7 +155,7 @@ void ImportProject::import(const std::string &filename)
|
|||
importCompileCommands(fin);
|
||||
} else if (filename.find(".sln") != std::string::npos) {
|
||||
std::string path(Path::getPathFromFilename(Path::fromNativeSeparators(filename)));
|
||||
if (!path.empty() && path[path.size()-1U] != '/')
|
||||
if (!path.empty() && path.back() != '/')
|
||||
path += '/';
|
||||
importSln(fin,path);
|
||||
} else if (filename.find(".vcxproj") != std::string::npos) {
|
||||
|
|
|
@ -87,7 +87,7 @@ Library::Error Library::load(const char exename[], const char path[])
|
|||
while (error == tinyxml2::XML_ERROR_FILE_NOT_FOUND && !cfgfolders.empty()) {
|
||||
const std::string cfgfolder(cfgfolders.front());
|
||||
cfgfolders.pop_front();
|
||||
const char *sep = (!cfgfolder.empty() && cfgfolder[cfgfolder.size()-1U]=='/' ? "" : "/");
|
||||
const char *sep = (!cfgfolder.empty() && cfgfolder.back()=='/' ? "" : "/");
|
||||
const std::string filename(cfgfolder + sep + fullfilename);
|
||||
error = doc.LoadFile(filename.c_str());
|
||||
if (error != tinyxml2::XML_ERROR_FILE_NOT_FOUND)
|
||||
|
|
|
@ -524,7 +524,7 @@ MathLib::bigint MathLib::toLongNumber(const std::string & str)
|
|||
return static_cast<bigint>(doubleval);
|
||||
}
|
||||
|
||||
if (str[0] == '\'' && str.size() >= 3U && str[str.size()-1U] == '\'') {
|
||||
if (str[0] == '\'' && str.size() >= 3U && str.back() == '\'') {
|
||||
return characterLiteralToLongNumber(str.substr(1,str.size()-2));
|
||||
}
|
||||
|
||||
|
|
|
@ -88,8 +88,7 @@ std::string Settings::addEnabled(const std::string &str)
|
|||
}
|
||||
|
||||
if (str == "all") {
|
||||
std::set<std::string>::const_iterator it;
|
||||
for (it = id.begin(); it != id.end(); ++it) {
|
||||
for (std::set<std::string>::const_iterator it = id.cbegin(); it != id.cend(); ++it) {
|
||||
if (*it == "internal")
|
||||
continue;
|
||||
|
||||
|
|
|
@ -215,12 +215,12 @@ private:
|
|||
|
||||
// This function ensure that test works with different compilers. Floats can
|
||||
// be stringified differently.
|
||||
std::string removeFloat(std::string errmsg) {
|
||||
std::string::size_type pos1 = errmsg.find("float (");
|
||||
std::string::size_type pos2 = errmsg.find(") conversion");
|
||||
std::string removeFloat(const std::string& msg) {
|
||||
std::string::size_type pos1 = msg.find("float (");
|
||||
std::string::size_type pos2 = msg.find(") conversion");
|
||||
if (pos1 == std::string::npos || pos2 == std::string::npos || pos1 > pos2)
|
||||
return errmsg;
|
||||
return errmsg.substr(0,pos1+7) + errmsg.substr(pos2);
|
||||
return msg;
|
||||
return msg.substr(0,pos1+7) + msg.substr(pos2);
|
||||
}
|
||||
|
||||
void checkFloatToIntegerOverflow() {
|
||||
|
|
Loading…
Reference in New Issue