Changeset

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
parents 11979:705c4c07a860
children 11981:5d8264f464a2
files plugins/mod_smacks.lua
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
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