aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-11-23 17:03:23 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-11-23 17:03:23 +0000
commitf2ca6b2e501c5d2e0be9489341ed2f46fc95d39f (patch)
tree4d50ca25c27e09f1433b399da9e3fa26a51e555a
parentcd18bb01870f5c1d63e249941f84170112975abf (diff)
downloadrspamd-f2ca6b2e501c5d2e0be9489341ed2f46fc95d39f.tar.gz
rspamd-f2ca6b2e501c5d2e0be9489341ed2f46fc95d39f.zip
[Minor] Simplify uniqueness check
-rw-r--r--src/plugins/lua/bayes_expiry.lua15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/plugins/lua/bayes_expiry.lua b/src/plugins/lua/bayes_expiry.lua
index 643ff29c6..d15ed43ac 100644
--- a/src/plugins/lua/bayes_expiry.lua
+++ b/src/plugins/lua/bayes_expiry.lua
@@ -418,24 +418,17 @@ rspamd_config:add_on_load(function (_, ev_base, worker)
local unique_redis_params = {}
-- Push redis script to all unique redis servers
for _,cls in ipairs(settings.classifiers) do
- local seen = false
- for _,rp in ipairs(unique_redis_params) do
- if lutil.table_cmp(rp, cls.redis_params) then
- seen = true
- end
- end
-
- if not seen then
- table.insert(unique_redis_params, cls.redis_params)
+ if not unique_redis_params[cls.redis_params.hash] then
+ unique_redis_params[cls.redis_params.hash] = cls.redis_params
end
end
- for _,rp in ipairs(unique_redis_params) do
+ for h,rp in pairs(unique_redis_params) do
local script_id = lredis.add_redis_script(lutil.template(expiry_script,
template), rp)
for _,cls in ipairs(settings.classifiers) do
- if lutil.table_cmp(rp, cls.redis_params) then
+ if cls.redis_params.hash == h then
cls.script = script_id
end
end