cmSearchPath: Drop unused parameter of ExtractWithout method

Also,

- Replace `std::set::count()` w/ `find()`
- Replace `push_back` w/ `emplace`
This commit is contained in:
Alex Turbov
2024-11-26 03:25:40 +04:00
committed by Brad King
parent 15b0feb704
commit c3c9bc035c
2 changed files with 7 additions and 12 deletions

View File

@@ -25,15 +25,11 @@ cmSearchPath::~cmSearchPath() = default;
void cmSearchPath::ExtractWithout(const std::set<std::string>& ignorePaths,
const std::set<std::string>& ignorePrefixes,
std::vector<std::string>& outPaths,
bool clear) const
std::vector<std::string>& outPaths) const
{
if (clear) {
outPaths.clear();
}
for (auto const& path : this->Paths) {
if (ignorePaths.count(path.Path) == 0 &&
ignorePrefixes.count(path.Prefix) == 0) {
if (ignorePaths.find(path.Path) == ignorePaths.end() &&
ignorePrefixes.find(path.Prefix) == ignorePrefixes.end()) {
outPaths.push_back(path.Path);
}
}
@@ -144,16 +140,16 @@ void cmSearchPath::AddSuffixes(const std::vector<std::string>& suffixes)
// path on windows and cause huge delays.
std::string p = inPath.Path;
if (!p.empty() && p.back() != '/') {
p += "/";
p += '/';
}
// Combine with all the suffixes
for (std::string const& suffix : suffixes) {
this->Paths.push_back(PathWithPrefix{ p + suffix, inPath.Prefix });
this->Paths.emplace_back(PathWithPrefix{ p + suffix, inPath.Prefix });
}
// And now the original w/o any suffix
this->Paths.push_back(std::move(inPath));
this->Paths.emplace_back(std::move(inPath));
}
}

View File

@@ -45,8 +45,7 @@ public:
void ExtractWithout(const std::set<std::string>& ignorePaths,
const std::set<std::string>& ignorePrefixes,
std::vector<std::string>& outPaths,
bool clear = false) const;
std::vector<std::string>& outPaths) const;
void AddPath(const std::string& path);
void AddUserPath(const std::string& path);