diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-08-08 21:43:08 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-08-08 21:43:08 +0100 |
commit | 3e2508b08f865d9da9cc23a28a76a916ebe0d7e3 (patch) | |
tree | 0918a3cbadcb603d39fc4198cbb76a42fd77a99b | |
parent | 5a60d2ad4763563296d4befee01942880d78df34 (diff) | |
download | rspamd-3e2508b08f865d9da9cc23a28a76a916ebe0d7e3.tar.gz rspamd-3e2508b08f865d9da9cc23a28a76a916ebe0d7e3.zip |
[Minor] Hide complex function
-rw-r--r-- | src/libserver/symcache/symcache_item.cxx | 25 | ||||
-rw-r--r-- | src/libserver/symcache/symcache_item.hxx | 24 |
2 files changed, 26 insertions, 23 deletions
diff --git a/src/libserver/symcache/symcache_item.cxx b/src/libserver/symcache/symcache_item.cxx index 7e44706dd..5f37de8a7 100644 --- a/src/libserver/symcache/symcache_item.cxx +++ b/src/libserver/symcache/symcache_item.cxx @@ -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) { diff --git a/src/libserver/symcache/symcache_item.hxx b/src/libserver/symcache/symcache_item.hxx index 594e4bddf..435a19abf 100644 --- a/src/libserver/symcache/symcache_item.hxx +++ b/src/libserver/symcache/symcache_item.hxx @@ -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 |