diff --git a/src/checksum.cpp b/src/checksum.cpp index fd4c7d4e..ed6747e5 100644 --- a/src/checksum.cpp +++ b/src/checksum.cpp @@ -25,7 +25,8 @@ #include #include #include -#include +#include +#include #include @@ -42,9 +43,11 @@ namespace dwarfs { namespace { -std::unordered_set supported_algorithms{ - "xxh3-64", - "xxh3-128", +using namespace std::string_view_literals; + +constexpr std::array supported_algorithms{ + "xxh3-64"sv, + "xxh3-128"sv, }; constexpr std::array unsupported_algorithms{ @@ -207,7 +210,10 @@ bool verify_impl(T&& alg, void const* data, size_t size, const void* digest, } // namespace bool checksum::is_available(std::string const& algo) { - return supported_algorithms.count(algo) or checksum_evp::is_available(algo); + // TODO: C++23: use std::ranges::contains + return std::ranges::find(supported_algorithms, algo) != + supported_algorithms.end() || + checksum_evp::is_available(algo); } std::vector checksum::available_algorithms() {