aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/css
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-06-18 12:56:50 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-06-18 12:56:50 +0100
commitf6321fbd323034d9763e53a56af014872a8a625a (patch)
tree4b32e28d1f66c00c4ed407380ea2b4fa49d3d909 /src/libserver/css
parent87366012b2a80090faa69b17b83f90da9f36f93b (diff)
downloadrspamd-f6321fbd323034d9763e53a56af014872a8a625a.tar.gz
rspamd-f6321fbd323034d9763e53a56af014872a8a625a.zip
[Minor] Add a simple utility to find a value in a map like stuff as an optional
Diffstat (limited to 'src/libserver/css')
-rw-r--r--src/libserver/css/css_property.cxx7
-rw-r--r--src/libserver/css/css_tokeniser.cxx6
2 files changed, 7 insertions, 6 deletions
diff --git a/src/libserver/css/css_property.cxx b/src/libserver/css/css_property.cxx
index 2a463f8da..1dd73026d 100644
--- a/src/libserver/css/css_property.cxx
+++ b/src/libserver/css/css_property.cxx
@@ -17,6 +17,7 @@
#include "css_property.hxx"
#include "frozen/unordered_map.h"
#include "frozen/string.h"
+#include "libutil/cxx/util.hxx"
namespace rspamd::css {
@@ -43,10 +44,10 @@ auto token_string_to_property(const std::string_view &inp)
css_property_type ret = css_property_type::PROPERTY_NYI;
- auto known_type = prop_names_map.find(inp);
+ auto known_type = find_map(prop_names_map, inp);
- if (known_type != prop_names_map.end()) {
- ret = known_type->second;
+ if (known_type) {
+ ret = known_type.value().get();
}
return ret;
diff --git a/src/libserver/css/css_tokeniser.cxx b/src/libserver/css/css_tokeniser.cxx
index 22544053c..2391140dd 100644
--- a/src/libserver/css/css_tokeniser.cxx
+++ b/src/libserver/css/css_tokeniser.cxx
@@ -154,10 +154,10 @@ css_parser_token::adjust_dim(const css_parser_token &dim_token) -> bool
auto num = std::get<float>(value);
auto sv = std::get<std::string_view>(dim_token.value);
- auto dim_found = dimensions_map.find(sv);
+ auto dim_found = find_map(dimensions_map, sv);
- if (dim_found != dimensions_map.end()) {
- auto dim_elt = dim_found->second;
+ if (dim_found) {
+ auto dim_elt = dim_found.value().get();
dimension_type = dim_elt.dtype;
flags |= css_parser_token::number_dimension;
num *= dim_elt.mult;