Small refactorizations:

- Avoid calling c_str() for functions that take std::string
- Avoid copying std::list
This commit is contained in:
PKEuS 2015-12-03 14:19:17 +01:00
parent 7f4dae8de4
commit 70767a30c4
2 changed files with 6 additions and 5 deletions

View File

@ -71,7 +71,7 @@ Library::Error Library::load(const char exename[], const char path[])
fullfilename += ".cfg"; fullfilename += ".cfg";
error = doc.LoadFile(fullfilename.c_str()); error = doc.LoadFile(fullfilename.c_str());
if (error != tinyxml2::XML_ERROR_FILE_NOT_FOUND) if (error != tinyxml2::XML_ERROR_FILE_NOT_FOUND)
absolute_path = Path::getAbsoluteFilePath(fullfilename.c_str()); absolute_path = Path::getAbsoluteFilePath(fullfilename);
} }
if (error == tinyxml2::XML_ERROR_FILE_NOT_FOUND) { if (error == tinyxml2::XML_ERROR_FILE_NOT_FOUND) {
@ -87,7 +87,7 @@ Library::Error Library::load(const char exename[], const char path[])
const std::string filename(cfgfolder + sep + fullfilename); const std::string filename(cfgfolder + sep + fullfilename);
error = doc.LoadFile(filename.c_str()); error = doc.LoadFile(filename.c_str());
if (error != tinyxml2::XML_ERROR_FILE_NOT_FOUND) if (error != tinyxml2::XML_ERROR_FILE_NOT_FOUND)
absolute_path = Path::getAbsoluteFilePath(filename.c_str()); absolute_path = Path::getAbsoluteFilePath(filename);
} }
} else } else
absolute_path = Path::getAbsoluteFilePath(path); absolute_path = Path::getAbsoluteFilePath(path);

View File

@ -2024,10 +2024,11 @@ static bool openHeader(std::string &filename, const std::list<std::string> &incl
return true; return true;
} }
std::list<std::string> includePaths2(includePaths); fin.open(filename.c_str());
includePaths2.push_front(""); if (fin.is_open())
return true;
for (std::list<std::string>::const_iterator iter = includePaths2.begin(); iter != includePaths2.end(); ++iter) { for (std::list<std::string>::const_iterator iter = includePaths.begin(); iter != includePaths.end(); ++iter) {
const std::string nativePath(Path::toNativeSeparators(*iter)); const std::string nativePath(Path::toNativeSeparators(*iter));
fin.open((nativePath + filename).c_str()); fin.open((nativePath + filename).c_str());
if (fin.is_open()) { if (fin.is_open()) {