]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Simplify code
authorVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 24 Jun 2022 20:52:17 +0000 (21:52 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 24 Jun 2022 20:52:17 +0000 (21:52 +0100)
src/libserver/css/css.cxx

index 9e26eb42f84e31101534906aac27367ed590c540..8958531329c5bab59c9ce14ea0836d927ff73f9f 100644 (file)
@@ -78,13 +78,10 @@ css_style_sheet::add_selector_rule(std::unique_ptr<css_selector> &&selector,
        }
 
        if (target_hash) {
-               auto found_it = target_hash->find(selector);
 
-               if (found_it == target_hash->end()) {
-                       /* Easy case, new element */
-                       target_hash->insert({std::move(selector), decls});
-               }
-               else {
+               auto [found_it, found] = target_hash->try_emplace(std::move(selector), decls);
+
+               if (found) {
                        /* 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