Remove Strings::is_empty(). Use std::string.empty()
MODIFY
include/vcpkg_Strings.h
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<class... Args>
std::string format(const char* fmtstr, const Args&... args)
{

MODIFY
src/BinaryParagraph.cpp
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());
}

MODIFY
src/vcpkg_Dependencies.cpp
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});

MODIFY
src/vcpkg_Strings.cpp
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<std::codecvt_utf8_utf16<wchar_t>, 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<std::string> split(const std::string& s, const std::string& delimiter)

MODIFY
src/vcpkglib.cpp
src/vcpkglib.cpp
@@ -189,7 +189,7 @@ namespace vcpkg
for (const std::unique_ptr<StatusParagraph>& pgh : status_db)
{
- if (pgh->state != InstallState::INSTALLED || !Strings::is_empty(pgh->package.feature))
+ if (pgh->state != InstallState::INSTALLED || !pgh->package.feature.empty())
{
continue;
}

Remove Strings::is_empty(). Use std::string.empty()