diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-12-14 16:34:35 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-12-14 16:34:35 +0000 |
commit | 65477c306436ca302709f32d15b975fbf4dc21eb (patch) | |
tree | 0bb197386c1738c624cd1da6384bf44a4cea1402 /lualib/redis_scripts/bayes_classify.lua | |
parent | 35479797646a4a1e5c4b0bfcb9a87d7e3b39dbcd (diff) | |
download | rspamd-65477c306436ca302709f32d15b975fbf4dc21eb.tar.gz rspamd-65477c306436ca302709f32d15b975fbf4dc21eb.zip |
[Project] Try to do strings concatenation in C
Diffstat (limited to 'lualib/redis_scripts/bayes_classify.lua')
-rw-r--r-- | lualib/redis_scripts/bayes_classify.lua | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lualib/redis_scripts/bayes_classify.lua b/lualib/redis_scripts/bayes_classify.lua index 1a4734cf5..e94f645fd 100644 --- a/lualib/redis_scripts/bayes_classify.lua +++ b/lualib/redis_scripts/bayes_classify.lua @@ -9,7 +9,6 @@ local output_ham = {} local learned_ham = tonumber(redis.call('HGET', prefix, 'learns_ham')) or 0 local learned_spam = tonumber(redis.call('HGET', prefix, 'learns_spam')) or 0 -local prefix_underscore = prefix .. '_' -- Output is a set of pairs (token_index, token_count), tokens that are not -- found are not filled. @@ -18,11 +17,11 @@ local prefix_underscore = prefix .. '_' if learned_ham > 0 and learned_spam > 0 then local input_tokens = cmsgpack.unpack(KEYS[2]) for i, token in ipairs(input_tokens) do - local token_data = redis.call('HMGET', prefix_underscore .. token, 'H', 'S') + local token_data = redis.call('HMGET', token, 'H', 'S') if token_data then local ham_count = token_data[1] - local spam_count = tonumber(token_data[2]) or 0 + local spam_count = token_data[2] if ham_count then table.insert(output_ham, { i, tonumber(ham_count) }) |