mirror of
https://github.com/transmission/transmission.git
synced 2026-02-14 23:19:34 +00:00
refactor: remove unused tr_variant initializer-list methods (#8002)
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
#include <cstddef> // size_t
|
||||
#include <cstdint> // int64_t
|
||||
#include <functional> // std::invoke
|
||||
#include <initializer_list>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
@@ -106,20 +105,6 @@ public:
|
||||
return find(key) != end(); // NOLINT(readability-container-contains)
|
||||
}
|
||||
|
||||
[[nodiscard]] TR_CONSTEXPR20 auto find(std::initializer_list<tr_quark> keys) noexcept
|
||||
{
|
||||
auto constexpr Predicate = [](auto const& item, tr_quark key)
|
||||
{
|
||||
return item.first == key;
|
||||
};
|
||||
return std::find_first_of(std::begin(vec_), std::end(vec_), std::begin(keys), std::end(keys), Predicate);
|
||||
}
|
||||
|
||||
[[nodiscard]] TR_CONSTEXPR20 auto find(std::initializer_list<tr_quark> keys) const noexcept
|
||||
{
|
||||
return Vector::const_iterator{ const_cast<Map*>(this)->find(keys) };
|
||||
}
|
||||
|
||||
[[nodiscard]] TR_CONSTEXPR20 auto size() const noexcept
|
||||
{
|
||||
return std::size(vec_);
|
||||
@@ -210,19 +195,6 @@ public:
|
||||
return const_cast<Map*>(this)->find_if<Type>(key);
|
||||
}
|
||||
|
||||
template<typename Type>
|
||||
[[nodiscard]] TR_CONSTEXPR20 auto* find_if(std::initializer_list<tr_quark> keys) noexcept
|
||||
{
|
||||
auto const iter = find(keys);
|
||||
return iter != end() ? iter->second.get_if<Type>() : nullptr;
|
||||
}
|
||||
|
||||
template<typename Type>
|
||||
[[nodiscard]] TR_CONSTEXPR20 auto* find_if(std::initializer_list<tr_quark> keys) const noexcept
|
||||
{
|
||||
return const_cast<Map*>(this)->find_if<Type>(keys);
|
||||
}
|
||||
|
||||
template<typename Type>
|
||||
[[nodiscard]] std::optional<Type> value_if(tr_quark const key) const noexcept
|
||||
{
|
||||
@@ -234,17 +206,6 @@ public:
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
template<typename Type>
|
||||
[[nodiscard]] std::optional<Type> value_if(std::initializer_list<tr_quark> keys) const noexcept
|
||||
{
|
||||
if (auto it = find(keys); it != end())
|
||||
{
|
||||
return it->second.value_if<Type>();
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
private:
|
||||
using Vector = std::vector<std::pair<tr_quark, tr_variant>>;
|
||||
Vector vec_;
|
||||
|
||||
Reference in New Issue
Block a user