mirror of
https://gitee.com/iresty/apisix.git
synced 2024-12-14 00:41:35 +08:00
perf: used empty table if the user is not enabled any plugin. (#1967)
This commit is contained in:
parent
4cbb324cca
commit
2073087909
@ -38,4 +38,5 @@ return {
|
||||
etcd = require("apisix.core.etcd"),
|
||||
http = require("apisix.core.http"),
|
||||
tablepool= require("tablepool"),
|
||||
empty_tab= {},
|
||||
}
|
||||
|
@ -451,8 +451,8 @@ function _M.http_access_phase()
|
||||
api_ctx.var.upstream_connection = api_ctx.var.http_connection
|
||||
end
|
||||
|
||||
local plugins = core.tablepool.fetch("plugins", 32, 0)
|
||||
api_ctx.plugins = plugin.filter(route, plugins)
|
||||
local plugins = plugin.filter(route)
|
||||
api_ctx.plugins = plugins
|
||||
|
||||
run_plugin("rewrite", plugins, api_ctx)
|
||||
if api_ctx.consumer then
|
||||
@ -631,7 +631,7 @@ function _M.http_log_phase()
|
||||
end
|
||||
|
||||
core.ctx.release_vars(api_ctx)
|
||||
if api_ctx.plugins then
|
||||
if api_ctx.plugins and api_ctx.plugins ~= core.empty_tab then
|
||||
core.tablepool.release("plugins", api_ctx.plugins)
|
||||
end
|
||||
|
||||
|
@ -229,16 +229,16 @@ end
|
||||
|
||||
|
||||
function _M.filter(user_route, plugins)
|
||||
plugins = plugins or core.table.new(#local_plugins * 2, 0)
|
||||
local user_plugin_conf = user_route.value.plugins
|
||||
if user_plugin_conf == nil or
|
||||
core.table.nkeys(user_plugin_conf) == 0 then
|
||||
if local_conf and local_conf.apisix.enable_debug then
|
||||
core.response.set_header("Apisix-Plugins", "no plugin")
|
||||
end
|
||||
return plugins
|
||||
return core.empty_tab
|
||||
end
|
||||
|
||||
plugins = plugins or core.tablepool.fetch("plugins", 32, 0)
|
||||
for _, plugin_obj in ipairs(local_plugins) do
|
||||
local name = plugin_obj.name
|
||||
local plugin_conf = user_plugin_conf[name]
|
||||
|
Loading…
Reference in New Issue
Block a user