summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2022-05-04 21:49:22 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2022-05-04 21:49:22 +0100
commitba79557df94aa5e8756914338063e59a61ac6328 (patch)
treeafcfd939e359e7402e9a719ccb090c4c67af4974
parente153d90011395d349b91cd60758c2887615ab6fc (diff)
downloadrspamd-ba79557df94aa5e8756914338063e59a61ac6328.tar.gz
rspamd-ba79557df94aa5e8756914338063e59a61ac6328.zip
[Project] Symcache: Use ordered filters to avoid extra lookups
-rw-r--r--src/libserver/symcache/symcache_runtime.cxx20
1 files 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;
}