From 70767a30c4fd03c60b290b0881b868f1e472439e Mon Sep 17 00:00:00 2001 From: PKEuS Date: Thu, 3 Dec 2015 14:19:17 +0100 Subject: [PATCH] Small refactorizations: - Avoid calling c_str() for functions that take std::string - Avoid copying std::list --- lib/library.cpp | 4 ++-- lib/preprocessor.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/library.cpp b/lib/library.cpp index 409033183..122565b68 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -71,7 +71,7 @@ Library::Error Library::load(const char exename[], const char path[]) fullfilename += ".cfg"; error = doc.LoadFile(fullfilename.c_str()); 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) { @@ -87,7 +87,7 @@ Library::Error Library::load(const char exename[], const char path[]) const std::string filename(cfgfolder + sep + fullfilename); error = doc.LoadFile(filename.c_str()); if (error != tinyxml2::XML_ERROR_FILE_NOT_FOUND) - absolute_path = Path::getAbsoluteFilePath(filename.c_str()); + absolute_path = Path::getAbsoluteFilePath(filename); } } else absolute_path = Path::getAbsoluteFilePath(path); diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 950273ae3..1177bbbee 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -2024,10 +2024,11 @@ static bool openHeader(std::string &filename, const std::list &incl return true; } - std::list includePaths2(includePaths); - includePaths2.push_front(""); + fin.open(filename.c_str()); + if (fin.is_open()) + return true; - for (std::list::const_iterator iter = includePaths2.begin(); iter != includePaths2.end(); ++iter) { + for (std::list::const_iterator iter = includePaths.begin(); iter != includePaths.end(); ++iter) { const std::string nativePath(Path::toNativeSeparators(*iter)); fin.open((nativePath + filename).c_str()); if (fin.is_open()) {