optimize(core): avoid useless comparisons in log.lua (#767)

This commit is contained in:
jackstraw 2019-10-31 08:12:13 +08:00 committed by YuanSheng Wang
parent b49b03d863
commit b3b09240a5

View File

@ -19,12 +19,12 @@ for name, log_level in pairs({stderr = ngx.STDERR,
warn = ngx.WARN,
notice = ngx.NOTICE,
info = ngx.INFO, }) do
_M[name] = function(...)
if cur_level and log_level > cur_level then
return
if cur_level and log_level > cur_level then
_M[name] = function() end
else
_M[name] = function(...)
return ngx_log(log_level, ...)
end
return ngx_log(log_level, ...)
end
end