From 70b1f665d973cfdbe493b21c4b3f9ecc2118fe28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Tue, 11 Jun 2024 14:14:38 +0200 Subject: [PATCH] removed redundant `Path::fromNativeSeparators()` calls (#6509) `Path::simplifyPath()` includes the operation --- cli/cmdlineparser.cpp | 4 ++-- lib/analyzerinfo.cpp | 6 +++--- lib/errorlogger.cpp | 3 +-- lib/importproject.cpp | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 6e02825ca08..2969b40db4a 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -897,7 +897,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a // Write results in file else if (std::strncmp(argv[i], "--output-file=", 14) == 0) - mSettings.outputFile = Path::simplifyPath(Path::fromNativeSeparators(argv[i] + 14)); + mSettings.outputFile = Path::simplifyPath(argv[i] + 14); // Experimental: limit execution time for extended valueflow analysis. basic valueflow analysis // is always executed. @@ -933,7 +933,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a // Write results in results.plist else if (std::strncmp(argv[i], "--plist-output=", 15) == 0) { - mSettings.plistOutput = Path::simplifyPath(Path::fromNativeSeparators(argv[i] + 15)); + mSettings.plistOutput = Path::simplifyPath(argv[i] + 15); if (mSettings.plistOutput.empty()) mSettings.plistOutput = "."; diff --git a/lib/analyzerinfo.cpp b/lib/analyzerinfo.cpp index 9c97788b021..9d5b914c2bd 100644 --- a/lib/analyzerinfo.cpp +++ b/lib/analyzerinfo.cpp @@ -53,14 +53,14 @@ void AnalyzerInformation::writeFilesTxt(const std::string &buildDir, const std:: std::ofstream fout(filesTxt); for (const std::string &f : sourcefiles) { const std::string afile = getFilename(f); - fout << afile << ".a" << (++fileCount[afile]) << "::" << Path::simplifyPath(Path::fromNativeSeparators(f)) << '\n'; + fout << afile << ".a" << (++fileCount[afile]) << "::" << Path::simplifyPath(f) << '\n'; if (!userDefines.empty()) - fout << afile << ".a" << (++fileCount[afile]) << ":" << userDefines << ":" << Path::simplifyPath(Path::fromNativeSeparators(f)) << '\n'; + fout << afile << ".a" << (++fileCount[afile]) << ":" << userDefines << ":" << Path::simplifyPath(f) << '\n'; } for (const FileSettings &fs : fileSettings) { const std::string afile = getFilename(fs.filename()); - fout << afile << ".a" << (++fileCount[afile]) << ":" << fs.cfg << ":" << Path::simplifyPath(Path::fromNativeSeparators(fs.filename())) << std::endl; + fout << afile << ".a" << (++fileCount[afile]) << ":" << fs.cfg << ":" << Path::simplifyPath(fs.filename()) << std::endl; } } diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp index 83946820517..17c5a82c977 100644 --- a/lib/errorlogger.cpp +++ b/lib/errorlogger.cpp @@ -731,8 +731,7 @@ std::string ErrorMessage::FileLocation::getOrigFile(bool convert) const void ErrorMessage::FileLocation::setfile(std::string file) { - mFileName = Path::fromNativeSeparators(std::move(file)); - mFileName = Path::simplifyPath(std::move(mFileName)); + mFileName = Path::simplifyPath(std::move(file)); } std::string ErrorMessage::FileLocation::stringify() const diff --git a/lib/importproject.cpp b/lib/importproject.cpp index e6453f4ddd0..7c7a45c61ec 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -138,7 +138,7 @@ static bool simplifyPathWithVariables(std::string &s, std::map