]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Hide complex function
authorVsevolod Stakhov <vsevolod@rspamd.com>
Mon, 8 Aug 2022 20:43:08 +0000 (21:43 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Mon, 8 Aug 2022 20:43:08 +0000 (21:43 +0100)
src/libserver/symcache/symcache_item.cxx
src/libserver/symcache/symcache_item.hxx

index 7e44706dde0a4d39b2f3bf75964121610cf72447..5f37de8a79c0ce34316c877c3e82ee87ca095d8a 100644 (file)
@@ -267,6 +267,31 @@ auto cache_item::update_counters_check_peak(lua_State *L,
        return ret;
 }
 
+auto cache_item::inc_frequency(const char *sym_name, symcache &cache) -> void
+{
+       if (sym_name && symbol != sym_name) {
+               if (is_filter()) {
+                       /* Likely a callback symbol with some virtual symbol that needs to be adjusted */
+                       for (const auto &cld: get_children().value().get()) {
+                               if (cld->get_name() == sym_name) {
+                                       cld->inc_frequency(sym_name, cache);
+                               }
+                       }
+               }
+               else {
+                       /* Name not equal to symbol name, so we need to find the proper name */
+                       auto *another_item = cache.get_item_by_name_mut(sym_name, false);
+                       if (another_item != nullptr) {
+                               another_item->inc_frequency(sym_name, cache);
+                       }
+               }
+       }
+       else {
+               /* Symbol and sym name are the same */
+               g_atomic_int_inc(&st->hits);
+       }
+}
+
 auto cache_item::get_type_str() const -> const char *
 {
        switch (type) {
index 594e4bddfaee607c9fff035e58af9fa031e3756a..435a19abf2b5b103095063f1a0adc12ece67dbd5 100644 (file)
@@ -343,29 +343,7 @@ public:
        /**
         * Increase frequency for a symbol
         */
-       auto inc_frequency(const char *sym_name, symcache &cache) -> void {
-               if (sym_name && symbol != sym_name) {
-                       if (is_filter()) {
-                               /* Likely a callback symbol with some virtual symbol that needs to be adjusted */
-                               for (const auto &cld: get_children().value().get()) {
-                                       if (cld->get_name() == sym_name) {
-                                               cld->inc_frequency(sym_name, cache);
-                                       }
-                               }
-                       }
-                       else {
-                               /* Name not equal to symbol name, so we need to find the proper name */
-                               auto *another_item = cache.get_item_by_name_mut(sym_name, false);
-                               if (another_item != nullptr) {
-                                       another_item->inc_frequency(sym_name, cache);
-                               }
-                       }
-               }
-               else {
-                       /* Symbol and sym name are the same */
-                       g_atomic_int_inc(&st->hits);
-               }
-       }
+       auto inc_frequency(const char *sym_name, symcache &cache) -> void;
 
        /**
         * Check if an item is allowed to be executed not checking item conditions