Skip to content

Commit

Permalink
perf: used table.new for plugins load. (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
moonming committed Jul 19, 2019
1 parent bc46bb3 commit 3eaa17c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lua/apisix/plugin.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
local require = require
local core = require("apisix.core")
local pkg_loaded = package.loaded
local insert_tab = table.insert
local sort_tab = table.sort
local pcall = pcall
local ipairs = ipairs
local pairs = pairs
local type = type
local local_plugins = {}
local local_plugins_hash = {}
local local_plugins = core.table.new(10, 0)
local local_plugins_hash = core.table.new(10, 0)


local _M = {
Expand Down Expand Up @@ -46,7 +45,7 @@ local function load_plugin(name)
end

plugin.name = name
insert_tab(local_plugins, plugin)
core.table.insert(local_plugins, plugin)

if plugin.init then
plugin.init()
Expand Down Expand Up @@ -145,8 +144,8 @@ function _M.filter(user_route, plugins)
local plugin_conf = user_plugin_conf[name]

if type(plugin_conf) == "table" and not plugin_conf.disable then
insert_tab(plugins, plugin_obj)
insert_tab(plugins, plugin_conf)
core.table.insert(plugins, plugin_obj)
core.table.insert(plugins, plugin_conf)
end
end

Expand Down

0 comments on commit 3eaa17c

Please sign in to comment.