From 5337adf1078f27c993f01662b7dadb8da2801356 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Tue, 29 Aug 2017 16:20:21 -0700 Subject: [PATCH] Remove Strings::is_empty(). Use std::string.empty() --- toolsrc/include/vcpkg_Strings.h | 3 --- toolsrc/src/BinaryParagraph.cpp | 2 +- toolsrc/src/vcpkg_Dependencies.cpp | 6 +++--- toolsrc/src/vcpkg_Strings.cpp | 5 +---- toolsrc/src/vcpkglib.cpp | 2 +- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/toolsrc/include/vcpkg_Strings.h b/toolsrc/include/vcpkg_Strings.h index 2607caf4ce..61f6fab610 100644 --- a/toolsrc/include/vcpkg_Strings.h +++ b/toolsrc/include/vcpkg_Strings.h @@ -39,9 +39,6 @@ namespace vcpkg::Strings static constexpr const char* EMPTY = ""; static constexpr const wchar_t* WEMPTY = L""; - bool is_empty(const CStringView s); - bool is_empty(const CWStringView s); - template std::string format(const char* fmtstr, const Args&... args) { diff --git a/toolsrc/src/BinaryParagraph.cpp b/toolsrc/src/BinaryParagraph.cpp index 1ab1aa63e1..1504912ab3 100644 --- a/toolsrc/src/BinaryParagraph.cpp +++ b/toolsrc/src/BinaryParagraph.cpp @@ -89,7 +89,7 @@ namespace vcpkg std::string BinaryParagraph::displayname() const { - const auto f = Strings::is_empty(this->feature) ? "core" : this->feature; + const auto f = this->feature.empty() ? "core" : this->feature; return Strings::format("%s[%s]:%s", this->spec.name(), f, this->spec.triplet()); } diff --git a/toolsrc/src/vcpkg_Dependencies.cpp b/toolsrc/src/vcpkg_Dependencies.cpp index 4d0c3c9287..1a0f0a6ed6 100644 --- a/toolsrc/src/vcpkg_Dependencies.cpp +++ b/toolsrc/src/vcpkg_Dependencies.cpp @@ -443,7 +443,7 @@ namespace vcpkg::Dependencies MarkPlusResult mark_plus(const std::string& feature, Cluster& cluster, ClusterGraph& graph, GraphPlan& graph_plan) { - if (feature == "") + if (feature.empty()) { // Indicates that core was not specified in the reference return mark_plus("core", cluster, graph, graph_plan); @@ -551,7 +551,7 @@ namespace vcpkg::Dependencies auto& status_paragraph_feature = status_paragraph->package.feature; // In this case, empty string indicates the "core" paragraph for a package. - if (status_paragraph_feature == "") + if (status_paragraph_feature.empty()) { cluster.original_features.insert("core"); } @@ -573,7 +573,7 @@ namespace vcpkg::Dependencies auto& dep_cluster = graph.get(dependency.spec()); auto depends_name = dependency.feature(); - if (depends_name == "") depends_name = "core"; + if (depends_name.empty()) depends_name = "core"; auto& target_node = dep_cluster.edges[depends_name]; target_node.remove_edges.emplace_back(FeatureSpec{spec, status_paragraph_feature}); diff --git a/toolsrc/src/vcpkg_Strings.cpp b/toolsrc/src/vcpkg_Strings.cpp index d08898bced..15851829d6 100644 --- a/toolsrc/src/vcpkg_Strings.cpp +++ b/toolsrc/src/vcpkg_Strings.cpp @@ -71,9 +71,6 @@ namespace vcpkg::Strings::details namespace vcpkg::Strings { - bool is_empty(const CStringView s) { return s == EMPTY; } - bool is_empty(const CWStringView s) { return s == WEMPTY; } - std::wstring to_utf16(const CStringView s) { std::wstring_convert, wchar_t> conversion; @@ -133,7 +130,7 @@ namespace vcpkg::Strings trim(&s); } - Util::erase_remove_if(*strings, [](const std::string& s) { return Strings::is_empty(s); }); + Util::erase_remove_if(*strings, [](const std::string& s) { return s.empty(); }); } std::vector split(const std::string& s, const std::string& delimiter) diff --git a/toolsrc/src/vcpkglib.cpp b/toolsrc/src/vcpkglib.cpp index 9f47c9d61c..14d062468a 100644 --- a/toolsrc/src/vcpkglib.cpp +++ b/toolsrc/src/vcpkglib.cpp @@ -189,7 +189,7 @@ namespace vcpkg for (const std::unique_ptr& pgh : status_db) { - if (pgh->state != InstallState::INSTALLED || !Strings::is_empty(pgh->package.feature)) + if (pgh->state != InstallState::INSTALLED || !pgh->package.feature.empty()) { continue; }