Software /
code /
prosody
Diff
plugins/mod_smacks.lua @ 11980:a91494a4c3d0
mod_smacks: Fix empty cache check
In Lua, every value except `nil` and `false` are considered true in
boolean expressions, even `0` as here, which means this was dead code.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 01 Dec 2021 23:03:11 +0100 |
parent | 11979:705c4c07a860 |
child | 11981:5d8264f464a2 |
line wrap: on
line diff
--- a/plugins/mod_smacks.lua Wed Dec 01 21:04:32 2021 +0100 +++ b/plugins/mod_smacks.lua Wed Dec 01 23:03:11 2021 +0100 @@ -70,7 +70,7 @@ if not stores[user] then stores[user] = cache.new(max_entries, evict_callback); end stores[user]:set(key, value); -- remove empty caches completely - if not stores[user]:count() then stores[user] = nil; end + if stores[user]:count() == 0 then stores[user] = nil; end end; }; end