diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-06-24 22:06:44 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-06-24 22:06:44 +0100 |
commit | 8242b83858ffd36337e01b43808ee4f2eade1b9e (patch) | |
tree | 8eb03f36c9b4efcc6c48f9638de31caf3d4612ff /src/libserver/css | |
parent | 8bb63981133b479dcaf24b9d34d43993c1b732c8 (diff) | |
download | rspamd-8242b83858ffd36337e01b43808ee4f2eade1b9e.tar.gz rspamd-8242b83858ffd36337e01b43808ee4f2eade1b9e.zip |
Revert "[Minor] Simplify code"
It seems that safety guarantees as defined by standard apply merely to the values but not to the keys.
So revert to a more ugly approach unless there is a better way to do `try_emplace` with move only key.
This reverts commit 8bb63981133b479dcaf24b9d34d43993c1b732c8.
Diffstat (limited to 'src/libserver/css')
-rw-r--r-- | src/libserver/css/css.cxx | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libserver/css/css.cxx b/src/libserver/css/css.cxx index 895853132..9e26eb42f 100644 --- a/src/libserver/css/css.cxx +++ b/src/libserver/css/css.cxx @@ -78,10 +78,13 @@ css_style_sheet::add_selector_rule(std::unique_ptr<css_selector> &&selector, } if (target_hash) { + auto found_it = target_hash->find(selector); - auto [found_it, found] = target_hash->try_emplace(std::move(selector), decls); - - if (found) { + if (found_it == target_hash->end()) { + /* Easy case, new element */ + target_hash->insert({std::move(selector), decls}); + } + else { /* The problem with merging is actually in how to handle selectors chains * For example, we have 2 selectors: * 1. class id tag -> meaning that we first match class, then we ensure that |