aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2022-07-17 16:43:47 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2022-07-17 16:43:47 +0100
commit969902f04569ab12e69e0d57ef1f6e9f0c42f855 (patch)
tree2d4ae6f19a613c4327e94da917aa89694dd2ff00 /src
parent93022e6207ed15f8dd231ad43511d7c9e3f2eee8 (diff)
downloadrspamd-969902f04569ab12e69e0d57ef1f6e9f0c42f855.tar.gz
rspamd-969902f04569ab12e69e0d57ef1f6e9f0c42f855.zip
[Rework] Use another version of hash table from the same author
Diffstat (limited to 'src')
-rw-r--r--src/libmime/received.cxx2
-rw-r--r--src/libmime/received.hxx8
-rw-r--r--src/libserver/composites/composites.cxx4
-rw-r--r--src/libserver/composites/composites_internal.hxx2
-rw-r--r--src/libserver/composites/composites_manager.cxx4
-rw-r--r--src/libserver/css/css.cxx4
-rw-r--r--src/libserver/css/css_colors_list.hxx4
-rw-r--r--src/libserver/css/css_rule.hxx4
-rw-r--r--src/libserver/css/css_value.cxx2
-rw-r--r--src/libserver/html/html_entities.cxx8
-rw-r--r--src/libserver/html/html_tag_defs.hxx6
-rw-r--r--src/libserver/redis_pool.cxx19
-rw-r--r--src/libserver/symcache/symcache_internal.hxx8
-rw-r--r--src/libserver/symcache/symcache_item.cxx2
-rw-r--r--src/libserver/symcache/symcache_item.hxx2
-rw-r--r--src/libstat/backends/cdb_backend.cxx4
-rw-r--r--src/libstat/backends/http_backend.cxx4
-rw-r--r--src/libutil/cxx/hash_util.hxx6
-rw-r--r--src/lua/lua_html.cxx4
19 files changed, 51 insertions, 46 deletions
diff --git a/src/libmime/received.cxx b/src/libmime/received.cxx
index 691d7ca04..8e0609f39 100644
--- a/src/libmime/received.cxx
+++ b/src/libmime/received.cxx
@@ -879,7 +879,7 @@ TEST_SUITE("received") {
TEST_CASE("parse received")
{
using namespace std::string_view_literals;
- using map_type = robin_hood::unordered_flat_map<std::string_view, std::string_view>;
+ using map_type = ankerl::unordered_dense::map<std::string_view, std::string_view>;
std::vector<std::pair<std::string_view, map_type>> cases{
// Simple received
{"from smtp11.mailtrack.pl (smtp11.mailtrack.pl [185.243.30.90])"sv,
diff --git a/src/libmime/received.hxx b/src/libmime/received.hxx
index 2edf628cc..a5d5e3fe6 100644
--- a/src/libmime/received.hxx
+++ b/src/libmime/received.hxx
@@ -24,7 +24,7 @@
#include "mime_string.hxx"
#include "libmime/email_addr.h"
#include "libserver/task.h"
-#include "contrib/robin-hood/robin_hood.h"
+#include "contrib/ankerl/unordered_dense.h"
#include <vector>
#include <string_view>
#include <utility>
@@ -179,7 +179,7 @@ struct received_header {
}
/* Unit tests helper */
- static auto from_map(const robin_hood::unordered_flat_map<std::string_view, std::string_view> &map) -> received_header {
+ static auto from_map(const ankerl::unordered_dense::map<std::string_view, std::string_view> &map) -> received_header {
using namespace std::string_view_literals;
received_header rh;
@@ -202,9 +202,9 @@ struct received_header {
return rh;
}
- auto as_map() const -> robin_hood::unordered_flat_map<std::string_view, std::string_view>
+ auto as_map() const -> ankerl::unordered_dense::map<std::string_view, std::string_view>
{
- robin_hood::unordered_flat_map<std::string_view, std::string_view> map;
+ ankerl::unordered_dense::map<std::string_view, std::string_view> map;
if (!from_hostname.empty()) {
map["from_hostname"] = from_hostname.as_view();
diff --git a/src/libserver/composites/composites.cxx b/src/libserver/composites/composites.cxx
index 3b5b274a7..9779b4678 100644
--- a/src/libserver/composites/composites.cxx
+++ b/src/libserver/composites/composites.cxx
@@ -25,7 +25,7 @@
#include <vector>
#include <variant>
#include "libutil/cxx/util.hxx"
-#include "contrib/robin-hood/robin_hood.h"
+#include "contrib/ankerl/unordered_dense.h"
#include "composites_internal.hxx"
@@ -82,7 +82,7 @@ struct composites_data {
struct rspamd_task *task;
struct rspamd_composite *composite;
struct rspamd_scan_result *metric_res;
- robin_hood::unordered_flat_map<std::string_view,
+ ankerl::unordered_dense::map<std::string_view,
std::vector<symbol_remove_data>> symbols_to_remove;
std::vector<bool> checked;
diff --git a/src/libserver/composites/composites_internal.hxx b/src/libserver/composites/composites_internal.hxx
index a12d5f9af..570cb4ea9 100644
--- a/src/libserver/composites/composites_internal.hxx
+++ b/src/libserver/composites/composites_internal.hxx
@@ -93,7 +93,7 @@ private:
return composite;
}
- robin_hood::unordered_flat_map<std::string,
+ ankerl::unordered_dense::map<std::string,
std::shared_ptr<rspamd_composite>, rspamd::smart_str_hash, rspamd::smart_str_equal> composites;
/* Store all composites here, even if we have duplicates */
std::vector<std::shared_ptr<rspamd_composite>> all_composites;
diff --git a/src/libserver/composites/composites_manager.cxx b/src/libserver/composites/composites_manager.cxx
index bf56fe675..27fb170b9 100644
--- a/src/libserver/composites/composites_manager.cxx
+++ b/src/libserver/composites/composites_manager.cxx
@@ -17,7 +17,7 @@
#include <memory>
#include <vector>
#include <cmath>
-#include "contrib/robin-hood/robin_hood.h"
+#include "contrib/ankerl/unordered_dense.h"
#include "composites.h"
#include "composites_internal.hxx"
@@ -29,7 +29,7 @@ namespace rspamd::composites {
static auto
composite_policy_from_str(const std::string_view &inp) -> enum rspamd_composite_policy
{
- const static robin_hood::unordered_flat_map<std::string_view,
+ const static ankerl::unordered_dense::map<std::string_view,
enum rspamd_composite_policy> names{
{"remove", rspamd_composite_policy::RSPAMD_COMPOSITE_POLICY_REMOVE_ALL},
{"remove_all", rspamd_composite_policy::RSPAMD_COMPOSITE_POLICY_REMOVE_ALL},
diff --git a/src/libserver/css/css.cxx b/src/libserver/css/css.cxx
index 9e26eb42f..7de4ab307 100644
--- a/src/libserver/css/css.cxx
+++ b/src/libserver/css/css.cxx
@@ -15,7 +15,7 @@
*/
#include "css.hxx"
-#include "contrib/robin-hood/robin_hood.h"
+#include "contrib/ankerl/unordered_dense.h"
#include "css_parser.hxx"
#include "libserver/html/html_tag.hxx"
#include "libserver/html/html_block.hxx"
@@ -34,7 +34,7 @@ public:
using sel_shared_hash = smart_ptr_hash<css_selector>;
using sel_shared_eq = smart_ptr_equal<css_selector>;
using selector_ptr = std::unique_ptr<css_selector>;
- using selectors_hash = robin_hood::unordered_flat_map<selector_ptr, css_declarations_block_ptr,
+ using selectors_hash = ankerl::unordered_dense::map<selector_ptr, css_declarations_block_ptr,
sel_shared_hash, sel_shared_eq>;
using universal_selector_t = std::pair<selector_ptr, css_declarations_block_ptr>;
selectors_hash tags_selector;
diff --git a/src/libserver/css/css_colors_list.hxx b/src/libserver/css/css_colors_list.hxx
index b1fc5d6ee..e880aa24b 100644
--- a/src/libserver/css/css_colors_list.hxx
+++ b/src/libserver/css/css_colors_list.hxx
@@ -20,7 +20,7 @@
#pragma once
#include <string_view>
-#include "contrib/robin-hood/robin_hood.h"
+#include "contrib/ankerl/unordered_dense.h"
#include "css_value.hxx"
namespace rspamd::css {
@@ -30,7 +30,7 @@ namespace rspamd::css {
* TODO: think about frozen structs when we can deal with 700 values without
* compiler limits...
*/
-static const robin_hood::unordered_flat_map<std::string_view, css_color> css_colors_map{
+static const ankerl::unordered_dense::map<std::string_view, css_color> css_colors_map{
{"aliceblue", {240, 248, 255}},
{"antiquewhite", {250, 235, 215}},
{"antiquewhite1", {255, 239, 219}},
diff --git a/src/libserver/css/css_rule.hxx b/src/libserver/css/css_rule.hxx
index acf44ba86..c942b8795 100644
--- a/src/libserver/css/css_rule.hxx
+++ b/src/libserver/css/css_rule.hxx
@@ -21,7 +21,7 @@
#include "css_value.hxx"
#include "css_property.hxx"
#include "css_parser.hxx"
-#include "contrib/robin-hood/robin_hood.h"
+#include "contrib/ankerl/unordered_dense.h"
#include "libutil/cxx/util.hxx"
#include "libutil/cxx/hash_util.hxx"
#include <vector>
@@ -121,7 +121,7 @@ public:
auto compile_to_block(rspamd_mempool_t *pool) const -> rspamd::html::html_block *;
private:
- robin_hood::unordered_flat_set<rule_shared_ptr, rule_shared_hash, rule_shared_eq> rules;
+ ankerl::unordered_dense::set<rule_shared_ptr, rule_shared_hash, rule_shared_eq> rules;
};
using css_declarations_block_ptr = std::shared_ptr<css_declarations_block>;
diff --git a/src/libserver/css/css_value.cxx b/src/libserver/css/css_value.cxx
index 6982647f4..7a451e1e5 100644
--- a/src/libserver/css/css_value.cxx
+++ b/src/libserver/css/css_value.cxx
@@ -19,7 +19,7 @@
#include "frozen/unordered_map.h"
#include "frozen/string.h"
#include "libutil/util.h"
-#include "contrib/robin-hood/robin_hood.h"
+#include "contrib/ankerl/unordered_dense.h"
#include "fmt/core.h"
#define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL
diff --git a/src/libserver/html/html_entities.cxx b/src/libserver/html/html_entities.cxx
index 8a3ff61da..f1bc91963 100644
--- a/src/libserver/html/html_entities.cxx
+++ b/src/libserver/html/html_entities.cxx
@@ -20,7 +20,7 @@
#include <string>
#include <utility>
#include <vector>
-#include <contrib/robin-hood/robin_hood.h>
+#include "contrib/ankerl/unordered_dense.h"
#include <unicode/utf8.h>
#include <unicode/uchar.h>
#include "libutil/cxx/util.hxx"
@@ -2168,9 +2168,9 @@ static const html_entity_def html_entities_array[] = {
};
class html_entities_storage {
- robin_hood::unordered_flat_map<std::string_view, html_entity_def> entity_by_name;
- robin_hood::unordered_flat_map<std::string_view, html_entity_def> entity_by_name_heur;
- robin_hood::unordered_flat_map<unsigned, html_entity_def> entity_by_id;
+ ankerl::unordered_dense::map<std::string_view, html_entity_def> entity_by_name;
+ ankerl::unordered_dense::map<std::string_view, html_entity_def> entity_by_name_heur;
+ ankerl::unordered_dense::map<unsigned, html_entity_def> entity_by_id;
public:
html_entities_storage() {
auto nelts = G_N_ELEMENTS(html_entities_array);
diff --git a/src/libserver/html/html_tag_defs.hxx b/src/libserver/html/html_tag_defs.hxx
index 812ec2021..e166e0b7c 100644
--- a/src/libserver/html/html_tag_defs.hxx
+++ b/src/libserver/html/html_tag_defs.hxx
@@ -21,7 +21,7 @@
#include "libutil/cxx/util.hxx"
#include <string>
-#include <contrib/robin-hood/robin_hood.h>
+#include "contrib/ankerl/unordered_dense.h"
namespace rspamd::html {
@@ -139,8 +139,8 @@ static const auto html_tag_defs_array = rspamd::array_of(
);
class html_tags_storage {
- robin_hood::unordered_flat_map<std::string_view, html_tag_def> tag_by_name;
- robin_hood::unordered_flat_map<tag_id_t, html_tag_def> tag_by_id;
+ ankerl::unordered_dense::map<std::string_view, html_tag_def> tag_by_name;
+ ankerl::unordered_dense::map<tag_id_t, html_tag_def> tag_by_id;
public:
html_tags_storage() {
tag_by_name.reserve(html_tag_defs_array.size());
diff --git a/src/libserver/redis_pool.cxx b/src/libserver/redis_pool.cxx
index 548551ab9..2ea8b727c 100644
--- a/src/libserver/redis_pool.cxx
+++ b/src/libserver/redis_pool.cxx
@@ -23,9 +23,8 @@
#include "contrib/hiredis/adapters/libev.h"
#include "cryptobox.h"
#include "logger.h"
-
#include <list>
-#include "contrib/robin-hood/robin_hood.h"
+#include "contrib/ankerl/unordered_dense.h"
namespace rspamd {
class redis_pool_elt;
@@ -91,6 +90,12 @@ class redis_pool_elt {
redis_pool_key_t key;
bool is_unix;
public:
+ /* Disable copy */
+ redis_pool_elt() = delete;
+ redis_pool_elt(const redis_pool_elt &) = delete;
+ /* Enable move */
+ redis_pool_elt(redis_pool_elt &&other) = default;
+
explicit redis_pool_elt(redis_pool *_pool,
const gchar *_db, const gchar *_password,
const char *_ip, int _port)
@@ -194,9 +199,9 @@ class redis_pool final {
static constexpr const unsigned default_max_conns = 100;
/* We want to have references integrity */
- robin_hood::unordered_flat_map<redisAsyncContext *,
+ ankerl::unordered_dense::map<redisAsyncContext *,
redis_pool_connection *> conns_by_ctx;
- robin_hood::unordered_node_map<redis_pool_key_t, redis_pool_elt> elts_by_key;
+ ankerl::unordered_dense::map<redis_pool_key_t, redis_pool_elt> elts_by_key;
bool wanna_die = false; /* Hiredis is 'clever' so we can call ourselves from destructor */
public:
double timeout = default_timeout;
@@ -490,9 +495,9 @@ redis_pool::new_connection(const gchar *db, const gchar *password,
}
else {
/* Need to create a pool */
- auto nelt = elts_by_key.emplace(std::piecewise_construct,
- std::forward_as_tuple(key),
- std::forward_as_tuple(this, db, password, ip, port));
+ auto nconn = redis_pool_elt{this, db, password, ip, port};
+ auto nelt = elts_by_key.try_emplace(key,
+ std::move(nconn));
return nelt.first->second.new_connection();
}
diff --git a/src/libserver/symcache/symcache_internal.hxx b/src/libserver/symcache/symcache_internal.hxx
index 9bce37532..063777a71 100644
--- a/src/libserver/symcache/symcache_internal.hxx
+++ b/src/libserver/symcache/symcache_internal.hxx
@@ -34,7 +34,7 @@
#include "rspamd_symcache.h"
#include "contrib/libev/ev.h"
-#include "contrib/robin-hood/robin_hood.h"
+#include "contrib/ankerl/unordered_dense.h"
#include "contrib/expected/expected.hpp"
#include "cfg_file.h"
@@ -109,9 +109,9 @@ struct order_generation {
/* All items ordered */
std::vector<cache_item_ptr> d;
/* Mapping from symbol name to the position in the order array */
- robin_hood::unordered_flat_map<std::string_view, unsigned int> by_symbol;
+ ankerl::unordered_dense::map<std::string_view, unsigned int> by_symbol;
/* Mapping from symbol id to the position in the order array */
- robin_hood::unordered_flat_map<unsigned int, unsigned int> by_cache_id;
+ ankerl::unordered_dense::map<unsigned int, unsigned int> by_cache_id;
/* It matches cache->generation_id; if not, a fresh ordering is required */
unsigned int generation_id;
@@ -147,7 +147,7 @@ class symcache {
private:
using items_ptr_vec = std::vector<cache_item_ptr>;
/* Map indexed by symbol name: all symbols must have unique names, so this map holds ownership */
- robin_hood::unordered_flat_map<std::string_view, cache_item_ptr> items_by_symbol;
+ ankerl::unordered_dense::map<std::string_view, cache_item_ptr> items_by_symbol;
items_ptr_vec items_by_id;
/* Items sorted into some order */
diff --git a/src/libserver/symcache/symcache_item.cxx b/src/libserver/symcache/symcache_item.cxx
index bdc378f32..588d2e93f 100644
--- a/src/libserver/symcache/symcache_item.cxx
+++ b/src/libserver/symcache/symcache_item.cxx
@@ -32,7 +32,7 @@ struct augmentation_info {
/* A list of internal augmentations that are known to Rspamd with their weight */
static const auto known_augmentations =
- robin_hood::unordered_flat_map<std::string, augmentation_info, rspamd::smart_str_hash, rspamd::smart_str_equal>{
+ ankerl::unordered_dense::map<std::string, augmentation_info, rspamd::smart_str_hash, rspamd::smart_str_equal>{
{"passthrough", {
.weight = 10,
.implied_flags = SYMBOL_TYPE_IGNORE_PASSTHROUGH
diff --git a/src/libserver/symcache/symcache_item.hxx b/src/libserver/symcache/symcache_item.hxx
index 2c2072fd3..50e321265 100644
--- a/src/libserver/symcache/symcache_item.hxx
+++ b/src/libserver/symcache/symcache_item.hxx
@@ -200,7 +200,7 @@ struct cache_item : std::enable_shared_from_this<cache_item> {
id_list forbidden_ids{};
/* Set of augmentations */
- robin_hood::unordered_flat_set<std::string, rspamd::smart_str_hash, rspamd::smart_str_equal> augmentations;
+ ankerl::unordered_dense::set<std::string, rspamd::smart_str_hash, rspamd::smart_str_equal> augmentations;
/* Dependencies */
std::vector<cache_dependency> deps;
diff --git a/src/libstat/backends/cdb_backend.cxx b/src/libstat/backends/cdb_backend.cxx
index d0915d2d7..5e188b978 100644
--- a/src/libstat/backends/cdb_backend.cxx
+++ b/src/libstat/backends/cdb_backend.cxx
@@ -27,7 +27,7 @@
#include <string>
#include <optional>
#include "contrib/expected/expected.hpp"
-#include "contrib/robin-hood/robin_hood.h"
+#include "contrib/ankerl/unordered_dense.h"
#include "fmt/core.h"
namespace rspamd::stat::cdb {
@@ -87,7 +87,7 @@ private:
* We store weak pointers here to allow owning cdb statfiles to free
* expensive cdb before this cache is terminated (e.g. on dynamic cdb reload)
*/
- robin_hood::unordered_flat_map<std::string, std::weak_ptr<struct cdb>> elts;
+ ankerl::unordered_dense::map<std::string, std::weak_ptr<struct cdb>> elts;
struct cdb_deleter {
void operator()(struct cdb *c) const {
diff --git a/src/libstat/backends/http_backend.cxx b/src/libstat/backends/http_backend.cxx
index 3f4f1abd0..69c735a09 100644
--- a/src/libstat/backends/http_backend.cxx
+++ b/src/libstat/backends/http_backend.cxx
@@ -19,7 +19,7 @@
#include "libserver/http/http_connection.h"
#include "libserver/mempool_vars_internal.h"
#include "upstream.h"
-#include "contrib/robin-hood/robin_hood.h"
+#include "contrib/ankerl/unordered_dense.h"
#include <vector>
namespace rspamd::stat::http {
@@ -91,7 +91,7 @@ public:
bool learn) -> bool;
private:
http_backends_collection *all_backends;
- robin_hood::unordered_flat_map<int, const struct rspamd_statfile_config *> seen_statfiles;
+ ankerl::unordered_dense::map<int, const struct rspamd_statfile_config *> seen_statfiles;
struct upstream *selected;
private:
http_backend_runtime(struct rspamd_task *task, bool is_learn) :
diff --git a/src/libutil/cxx/hash_util.hxx b/src/libutil/cxx/hash_util.hxx
index d8529774e..afad29fa5 100644
--- a/src/libutil/cxx/hash_util.hxx
+++ b/src/libutil/cxx/hash_util.hxx
@@ -20,7 +20,7 @@
#include <string_view>
#include <string>
-#include "contrib/robin-hood/robin_hood.h"
+#include "contrib/ankerl/unordered_dense.h"
namespace rspamd {
@@ -81,10 +81,10 @@ struct smart_str_equal {
struct smart_str_hash {
using is_transparent = void;
auto operator()(const std::string &a) const {
- return robin_hood::hash<std::string>()(a);
+ return ankerl::unordered_dense::hash<std::string>()(a);
}
auto operator()(const std::string_view &a) const {
- return robin_hood::hash<std::string_view>()(a);
+ return ankerl::unordered_dense::hash<std::string_view>()(a);
}
};
diff --git a/src/lua/lua_html.cxx b/src/lua/lua_html.cxx
index 666b08a60..cecf4bb5c 100644
--- a/src/lua/lua_html.cxx
+++ b/src/lua/lua_html.cxx
@@ -21,7 +21,7 @@
#include "libserver/html/html_block.hxx"
#include "images.h"
-#include <contrib/robin-hood/robin_hood.h>
+#include "contrib/ankerl/unordered_dense.h"
#include <frozen/string.h>
#include <frozen/unordered_map.h>
@@ -406,7 +406,7 @@ lua_html_foreach_tag (lua_State *L)
const gchar *tagname;
gint id;
auto any = false;
- robin_hood::unordered_flat_set<int> tags;
+ ankerl::unordered_dense::set<int> tags;
if (lua_type (L, 2) == LUA_TSTRING) {