this allows us to find by string without creating a std::string
instance, even if this string is not nul terminated.
Signed-off-by: Kefu Chai <kchai@redhat.com>
return p->first;
}
-boost::optional<Compressor::CompressionAlgorithm> Compressor::get_comp_alg_type(const std::string &s) {
+boost::optional<Compressor::CompressionAlgorithm>
+Compressor::get_comp_alg_type(std::string_view s) {
auto p = std::find_if(std::cbegin(compression_algorithms), std::cend(compression_algorithms),
[&s](const auto& kv) { return kv.first == s; });
default: return "???";
}
}
-boost::optional<Compressor::CompressionMode> Compressor::get_comp_mode_type(const std::string &s) {
+boost::optional<Compressor::CompressionMode>
+Compressor::get_comp_mode_type(std::string_view s) {
if (s == "force")
return COMP_FORCE;
if (s == "aggressive")
#endif
static const char* get_comp_alg_name(int a);
- static boost::optional<CompressionAlgorithm> get_comp_alg_type(const std::string &s);
+ static boost::optional<CompressionAlgorithm> get_comp_alg_type(std::string_view s);
static const char *get_comp_mode_name(int m);
- static boost::optional<CompressionMode> get_comp_mode_type(const std::string &s);
+ static boost::optional<CompressionMode> get_comp_mode_type(std::string_view s);
Compressor(CompressionAlgorithm a, const char* t) : alg(a), type(t) {
}