aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/vcpkg.cpp
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2016-12-15 18:41:01 -0800
committerAlexander Karatarakis <alkarata@microsoft.com>2016-12-15 18:41:01 -0800
commit38859d5c91c6411fb2b0757a68fd3ca297927650 (patch)
treeea73592c3d95b0d5c236dfaeeecb660879d69853 /toolsrc/src/vcpkg.cpp
parent15ca6919ad7d5dd86596603663845b3ea84d0d3b (diff)
downloadvcpkg-38859d5c91c6411fb2b0757a68fd3ca297927650.tar.gz
vcpkg-38859d5c91c6411fb2b0757a68fd3ca297927650.zip
Improve code that filters out the directories from a vector of paths
Diffstat (limited to 'toolsrc/src/vcpkg.cpp')
-rw-r--r--toolsrc/src/vcpkg.cpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp
index 98c53f9ef..8d01cb267 100644
--- a/toolsrc/src/vcpkg.cpp
+++ b/toolsrc/src/vcpkg.cpp
@@ -182,8 +182,6 @@ static void upgrade_to_slash_terminated_sorted_format(std::vector<std::string>*
std::vector<StatusParagraph_and_associated_files> vcpkg::get_installed_files(const vcpkg_paths& paths, const StatusParagraphs& status_db)
{
- static const std::string MARK_FOR_REMOVAL = "";
-
std::vector<StatusParagraph_and_associated_files> installed_files;
std::string line;
@@ -211,19 +209,13 @@ std::vector<StatusParagraph_and_associated_files> vcpkg::get_installed_files(con
listfile.close();
upgrade_to_slash_terminated_sorted_format(&installed_files_of_current_pgh, listfile_path);
- for (std::string& file : installed_files_of_current_pgh)
- {
- if (file.back() == '/')
- {
- file = MARK_FOR_REMOVAL;
- }
- }
-
- installed_files_of_current_pgh.erase(std::remove_if(installed_files_of_current_pgh.begin(), installed_files_of_current_pgh.end(), [](const std::string& file)
- {
- return file == MARK_FOR_REMOVAL;
- }),
- installed_files_of_current_pgh.end());
+ // Remove the directories
+ installed_files_of_current_pgh.erase(
+ std::remove_if(installed_files_of_current_pgh.begin(), installed_files_of_current_pgh.end(), [](const std::string& file) -> bool
+ {
+ return file.back() == '/';
+ }
+ ), installed_files_of_current_pgh.end());
StatusParagraph_and_associated_files pgh_and_files = {*pgh, std::move(installed_files_of_current_pgh)};
installed_files.push_back(std::move(pgh_and_files));