commit ba79557: [Project] Symcache: Use ordered filters to avoid extra lookups
Vsevolod Stakhov
vsevolod at rspamd.com
Wed May 4 22:56:04 UTC 2022
Author: Vsevolod Stakhov
Date: 2022-05-04 21:49:22 +0100
URL: https://github.com/rspamd/rspamd/commit/ba79557df94aa5e8756914338063e59a61ac6328 (HEAD -> master)
[Project] Symcache: Use ordered filters to avoid extra lookups
---
src/libserver/symcache/symcache_runtime.cxx | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/src/libserver/symcache/symcache_runtime.cxx b/src/libserver/symcache/symcache_runtime.cxx
index c8c8e9e89..7ee8b9cd9 100644
--- a/src/libserver/symcache/symcache_runtime.cxx
+++ b/src/libserver/symcache/symcache_runtime.cxx
@@ -423,31 +423,31 @@ symcache_runtime::process_filters(struct rspamd_task *task, symcache &cache, int
{
auto all_done = true;
- cache.filters_foreach([&](cache_item *item) -> bool {
+ for (const auto [idx, item] : rspamd::enumerate(order->d)) {
if (item->type == symcache_item_type::CLASSIFIER) {
- return true;
+ continue;
}
- auto dyn_item = get_dynamic_item(item->id, true);
+ auto dyn_item = &dynamic_items[idx];
if (!dyn_item->started && !dyn_item->finished) {
all_done = false;
- if (!check_item_deps(task, cache, item,
+ if (!check_item_deps(task, cache, item.get(),
dyn_item, false)) {
msg_debug_cache_task("blocked execution of %d(%s) unless deps are "
"resolved", item->id, item->symbol.c_str());
- return true;
+ break;
}
- process_symbol(task, cache, item, dyn_item);
+ process_symbol(task, cache, item.get(), dyn_item);
if (has_slow) {
/* Delay */
has_slow = false;
- return false;
+ break;
}
}
@@ -458,12 +458,10 @@ symcache_runtime::process_filters(struct rspamd_task *task, symcache &cache, int
"plan more checks",
rs->score);
all_done = true;
- return false;
+ break;
}
}
-
- return true;
- });
+ }
return all_done;
}
More information about the Commits
mailing list