aboutsummaryrefslogtreecommitdiff
path: root/toolsrc
diff options
context:
space:
mode:
Diffstat (limited to 'toolsrc')
-rw-r--r--toolsrc/include/vcpkg_Util.h2
-rw-r--r--toolsrc/src/commands_build.cpp4
-rw-r--r--toolsrc/src/commands_hash.cpp2
-rw-r--r--toolsrc/src/commands_integrate.cpp5
-rw-r--r--toolsrc/src/vcpkg_Dependencies.cpp8
-rw-r--r--toolsrc/src/vcpkg_Strings.cpp5
-rw-r--r--toolsrc/src/vcpkglib.cpp5
7 files changed, 11 insertions, 20 deletions
diff --git a/toolsrc/include/vcpkg_Util.h b/toolsrc/include/vcpkg_Util.h
index c717830f0..86fec8ea9 100644
--- a/toolsrc/include/vcpkg_Util.h
+++ b/toolsrc/include/vcpkg_Util.h
@@ -29,7 +29,7 @@ namespace vcpkg::Util
}
template<class Container, class Pred>
- void keep_if(Container& cont, Pred pred)
+ void erase_remove_if(Container& cont, Pred pred)
{
cont.erase(std::remove_if(cont.begin(), cont.end(), pred), cont.end());
}
diff --git a/toolsrc/src/commands_build.cpp b/toolsrc/src/commands_build.cpp
index 9110e1fd0..ab792f1bc 100644
--- a/toolsrc/src/commands_build.cpp
+++ b/toolsrc/src/commands_build.cpp
@@ -150,9 +150,9 @@ namespace vcpkg::Commands::Build
if (result == BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES)
{
std::vector<InstallPlanAction> unmet_dependencies = Dependencies::create_install_plan(paths, { spec }, status_db);
- Util::keep_if(unmet_dependencies, [&spec](const InstallPlanAction& p)
+ Util::erase_remove_if(unmet_dependencies, [&spec](const InstallPlanAction& p)
{
- return (p.spec != spec) && (p.plan_type != InstallPlanType::ALREADY_INSTALLED);
+ return (p.spec == spec) || (p.plan_type == InstallPlanType::ALREADY_INSTALLED);
});
Checks::check_exit(VCPKG_LINE_INFO, !unmet_dependencies.empty());
diff --git a/toolsrc/src/commands_hash.cpp b/toolsrc/src/commands_hash.cpp
index a9024d9e7..b6355dfbd 100644
--- a/toolsrc/src/commands_hash.cpp
+++ b/toolsrc/src/commands_hash.cpp
@@ -21,7 +21,7 @@ namespace vcpkg::Commands::Hash
Checks::check_exit(VCPKG_LINE_INFO, end != std::string::npos, "Unexpected output format from command: %s", Strings::utf16_to_utf8(cmd_line));
auto hash = output.substr(start, end - start);
- Util::keep_if(hash, [](char c) {return !isspace(c); });
+ Util::erase_remove_if(hash, isspace);
System::println(hash);
}
diff --git a/toolsrc/src/commands_integrate.cpp b/toolsrc/src/commands_integrate.cpp
index 819c29082..5772843df 100644
--- a/toolsrc/src/commands_integrate.cpp
+++ b/toolsrc/src/commands_integrate.cpp
@@ -67,10 +67,7 @@ namespace vcpkg::Commands::Integrate
dir_id.erase(1, 1); // Erasing the ":"
// NuGet id cannot have invalid characters. We will only use alphanumeric and dot.
- Util::keep_if(dir_id, [](char c)
- {
- return isalnum(c) || (c == '.');
- });
+ Util::erase_remove_if(dir_id, [](char c) { return !isalnum(c) && (c != '.'); });
const std::string nuget_id = "vcpkg." + dir_id;
return nuget_id;
diff --git a/toolsrc/src/vcpkg_Dependencies.cpp b/toolsrc/src/vcpkg_Dependencies.cpp
index 03e3c2aeb..151ee28f4 100644
--- a/toolsrc/src/vcpkg_Dependencies.cpp
+++ b/toolsrc/src/vcpkg_Dependencies.cpp
@@ -143,10 +143,10 @@ namespace vcpkg::Dependencies
const std::unordered_set<PackageSpec> specs_as_set(specs.cbegin(), specs.cend());
std::vector<InstallPlanAction> toposort = Graphs::topological_sort(specs, InstallAdjacencyProvider{ paths, status_db, specs_as_set });
- Util::keep_if(toposort, [](const InstallPlanAction& p)
- {
- return !(p.request_type == RequestType::AUTO_SELECTED && p.plan_type == InstallPlanType::ALREADY_INSTALLED);
- });
+ Util::erase_remove_if(toposort, [](const InstallPlanAction& p)
+ {
+ return p.request_type == RequestType::AUTO_SELECTED && p.plan_type == InstallPlanType::ALREADY_INSTALLED;
+ });
return toposort;
}
diff --git a/toolsrc/src/vcpkg_Strings.cpp b/toolsrc/src/vcpkg_Strings.cpp
index 3d9895436..5f46af6d2 100644
--- a/toolsrc/src/vcpkg_Strings.cpp
+++ b/toolsrc/src/vcpkg_Strings.cpp
@@ -99,10 +99,7 @@ namespace vcpkg::Strings
trim(&s);
}
- Util::keep_if(*strings, [](const std::string& s)-> bool
- {
- return s != "";
- });
+ Util::erase_remove_if(*strings, [](const std::string& s) { return s == ""; });
}
std::vector<std::string> split(const std::string& s, const std::string& delimiter)
diff --git a/toolsrc/src/vcpkglib.cpp b/toolsrc/src/vcpkglib.cpp
index 7f2d737cb..90d3e99b9 100644
--- a/toolsrc/src/vcpkglib.cpp
+++ b/toolsrc/src/vcpkglib.cpp
@@ -201,10 +201,7 @@ namespace vcpkg
upgrade_to_slash_terminated_sorted_format(fs, &installed_files_of_current_pgh, listfile_path);
// Remove the directories
- Util::keep_if(installed_files_of_current_pgh, [](const std::string& file) -> bool
- {
- return file.back() != '/';
- });
+ Util::erase_remove_if(installed_files_of_current_pgh, [](const std::string& file) { return file.back() == '/'; });
StatusParagraphAndAssociatedFiles pgh_and_files = { *pgh, SortedVector<std::string>(std::move(installed_files_of_current_pgh)) };
installed_files.push_back(std::move(pgh_and_files));