From 40ea5f2ee0ace663af86d4be46c6d2acdcf92eb6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Wed, 31 Jul 2019 15:55:43 +0200 Subject: [PATCH] modules/policy: optimize postrules I've never seen anyone use postrules. --- modules/policy/policy.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/policy/policy.lua b/modules/policy/policy.lua index cf6a0b738..d78e0f0ac 100644 --- a/modules/policy/policy.lua +++ b/modules/policy/policy.lua @@ -591,6 +591,8 @@ policy.layer = { state end, finish = function(state, req) + -- Optimization for the typical case + if #policy.postrules == 0 then return state end -- Don't act on "resolved" cases. if bit.band(state, bit.bor(kres.FAIL, kres.DONE)) ~= 0 then return state end return policy.evaluate(policy.postrules, req, req:current(), state) or state -- 2.47.2