]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Move an upvalue check out of the closure returned by gen_check_closure()
authorDmitry Petrov <dpetrov67@gmail.com>
Wed, 5 Mar 2025 14:18:05 +0000 (09:18 -0500)
committerDmitry Petrov <dpetrov67@gmail.com>
Wed, 5 Mar 2025 14:18:05 +0000 (09:18 -0500)
src/plugins/lua/settings.lua

index 51622fb91dc093f6f1d0b790310412ef430d3e48..0f8e007237e5f87c385ec978d44e1f2f6712277b 100644 (file)
@@ -617,6 +617,12 @@ end
 
 -- Used to create a checking closure: if value matches expected somehow, return true
 local function gen_check_closure(expected, check_func)
+  if not check_func then
+    check_func = function(a, b)
+      return a == b
+    end
+  end
+
   return function(value)
     if not value then
       return false
@@ -627,13 +633,6 @@ local function gen_check_closure(expected, check_func)
     end
 
     if value then
-
-      if not check_func then
-        check_func = function(a, b)
-          return a == b
-        end
-      end
-
       local ret
       if type(expected) == 'table' then
         ret = fun.any(function(d)