Skip to content

Commit

Permalink
[Minor] Add is_avalanching type hint
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Jul 18, 2022
1 parent 788b7d3 commit 4c12780
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/libserver/css/css_property.hxx
Expand Up @@ -141,6 +141,7 @@ namespace std {
template<>
class hash<rspamd::css::css_property> {
public:
using is_avalanching = void;
/* Mix bits to provide slightly better distribution but being constexpr */
constexpr size_t operator() (const rspamd::css::css_property &prop) const {
std::size_t key = 0xdeadbeef ^static_cast<std::size_t>(prop.type);
Expand Down
1 change: 1 addition & 0 deletions src/libserver/css/css_rule.hxx
Expand Up @@ -73,6 +73,7 @@ namespace std {
template<>
class hash<rspamd::css::css_rule> {
public:
using is_avalanching = void;
constexpr auto operator()(const rspamd::css::css_rule &rule) const -> auto {
return hash<rspamd::css::css_property>()(rule.get_prop());
}
Expand Down
1 change: 1 addition & 0 deletions src/libserver/css/css_selector.hxx
Expand Up @@ -106,6 +106,7 @@ namespace std {
template<>
class hash<rspamd::css::css_selector> {
public:
using is_avalanching = void;
auto operator() (const rspamd::css::css_selector &sel) const -> std::size_t {
if (sel.type == rspamd::css::css_selector::selector_type::SELECTOR_TAG) {
return static_cast<std::size_t>(std::get<tag_id_t>(sel.value));
Expand Down
1 change: 1 addition & 0 deletions src/libutil/cxx/hash_util.hxx
Expand Up @@ -80,6 +80,7 @@ struct smart_str_equal {

struct smart_str_hash {
using is_transparent = void;
using is_avalanching = typename ankerl::unordered_dense::hash<std::string_view>::is_avalanching;
auto operator()(const std::string &a) const {
return ankerl::unordered_dense::hash<std::string>()(a);
}
Expand Down

0 comments on commit 4c12780

Please sign in to comment.