This is an automated email from the ASF dual-hosted git repository.
spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 8c3bbe0 chore: the buf doesn't bring any performance improvement but
make code complex (#5317)
8c3bbe0 is described below
commit 8c3bbe0ede4d615bf9bc9ae9087690dd017351d6
Author: 罗泽轩 <[email protected]>
AuthorDate: Sun Oct 24 11:34:08 2021 +0800
chore: the buf doesn't bring any performance improvement but make code
complex (#5317)
---
apisix/core/lrucache.lua | 44 ++++++++++++++------------------------------
apisix/wasm.lua | 15 ++-------------
2 files changed, 16 insertions(+), 43 deletions(-)
diff --git a/apisix/core/lrucache.lua b/apisix/core/lrucache.lua
index 9bc5c6f..97c23ec 100644
--- a/apisix/core/lrucache.lua
+++ b/apisix/core/lrucache.lua
@@ -19,7 +19,6 @@ local lru_new = require("resty.lrucache").new
local resty_lock = require("resty.lock")
local log = require("apisix.core.log")
local tostring = tostring
-local concat = table.concat
local ngx = ngx
local get_phase = ngx.get_phase
@@ -139,39 +138,24 @@ end
global_lru_fun = new_lru_fun()
-local plugin_ctx, plugin_ctx_id
-do
- local key_buf = {
- nil,
- nil,
- nil,
- nil,
- }
-
- local function plugin_ctx_key_and_ver(api_ctx, extra_key)
- key_buf[1] = api_ctx.conf_type
- key_buf[2] = api_ctx.conf_id
-
- local key
- if extra_key then
- key_buf[3] = extra_key
- key = concat(key_buf, "#", 1, 3)
- else
- key = concat(key_buf, "#", 1, 2)
- end
+local function plugin_ctx_key_and_ver(api_ctx, extra_key)
+ local key = api_ctx.conf_type .. "#" .. api_ctx.conf_id
- return key, api_ctx.conf_version
+ if extra_key then
+ key = key .. "#" .. extra_key
end
- function plugin_ctx(lrucache, api_ctx, extra_key, create_obj_func, ...)
- local key, ver = plugin_ctx_key_and_ver(api_ctx, extra_key)
- return lrucache(key, ver, create_obj_func, ...)
- end
+ return key, api_ctx.conf_version
+end
- function plugin_ctx_id(api_ctx, extra_key)
- local key, ver = plugin_ctx_key_and_ver(api_ctx, extra_key)
- return key .. "#" .. ver
- end
+local function plugin_ctx(lrucache, api_ctx, extra_key, create_obj_func, ...)
+ local key, ver = plugin_ctx_key_and_ver(api_ctx, extra_key)
+ return lrucache(key, ver, create_obj_func, ...)
+end
+
+local function plugin_ctx_id(api_ctx, extra_key)
+ local key, ver = plugin_ctx_key_and_ver(api_ctx, extra_key)
+ return key .. "#" .. ver
end
diff --git a/apisix/wasm.lua b/apisix/wasm.lua
index d018e59..c99731a 100644
--- a/apisix/wasm.lua
+++ b/apisix/wasm.lua
@@ -16,7 +16,6 @@
--
local core = require("apisix.core")
local support_wasm, wasm = pcall(require, "resty.proxy-wasm")
-local concat = table.concat
local schema = {
@@ -36,18 +35,8 @@ local function check_schema(conf)
end
-local get_plugin_ctx_key
-do
- local key_buf = {
- nil,
- nil,
- }
-
- function get_plugin_ctx_key(ctx)
- key_buf[1] = ctx.conf_type
- key_buf[2] = ctx.conf_id
- return concat(key_buf, "#", 1, 2)
- end
+local function get_plugin_ctx_key(ctx)
+ return ctx.conf_type .. "#" .. ctx.conf_id
end
local function fetch_plugin_ctx(conf, ctx, plugin)