From: Vladimír Čunát Date: Wed, 31 Jul 2019 13:55:43 +0000 (+0200) Subject: modules/policy: optimize postrules X-Git-Tag: v4.3.0~4^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40ea5f2ee0ace663af86d4be46c6d2acdcf92eb6;p=thirdparty%2Fknot-resolver.git modules/policy: optimize postrules I've never seen anyone use postrules. --- 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