From 6f47e8654f5341bded3698c05f867dd0e5e63905 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 14 May 2022 12:30:12 +0100 Subject: [PATCH] [Minor] Composites companion --- .../composites/composites_internal.hxx | 27 ++----------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/src/libserver/composites/composites_internal.hxx b/src/libserver/composites/composites_internal.hxx index d6c8f3d69..a12d5f9af 100644 --- a/src/libserver/composites/composites_internal.hxx +++ b/src/libserver/composites/composites_internal.hxx @@ -20,6 +20,7 @@ #include #include "libutil/expression.h" +#include "libutil/cxx/hash_util.hxx" #include "libserver/cfg_file.h" namespace rspamd::composites { @@ -78,30 +79,6 @@ private: delete COMPOSITE_MANAGER_FROM_PTR(ptr); } - /* Enable lookup by string view */ - struct smart_str_equal { - using is_transparent = void; - auto operator()(const std::string &a, const std::string &b) const { - return a == b; - } - auto operator()(const std::string_view &a, const std::string &b) const { - return a == b; - } - auto operator()(const std::string &a, const std::string_view &b) const { - return a == b; - } - }; - - struct smart_str_hash { - using is_transparent = void; - auto operator()(const std::string &a) const { - return robin_hood::hash()(a); - } - auto operator()(const std::string_view &a) const { - return robin_hood::hash()(a); - } - }; - auto new_composite(std::string_view composite_name, rspamd_expression *expr, std::string_view composite_expression) -> auto { @@ -117,7 +94,7 @@ private: } robin_hood::unordered_flat_map, smart_str_hash, smart_str_equal> composites; + std::shared_ptr, rspamd::smart_str_hash, rspamd::smart_str_equal> composites; /* Store all composites here, even if we have duplicates */ std::vector> all_composites; struct rspamd_config *cfg; -- 2.39.5