Skip to content

Commit 4cbd997

Browse files
xuruidongmywildquant
authored andcommitted
perf(aws-lambda): cache the index of the array (#9944)
1 parent 9cc21f0 commit 4cbd997

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

apisix/plugins/aws-lambda.lua

+6-2
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,10 @@ local function request_processor(conf, ctx, params)
122122

123123
-- computing canonical query string
124124
local canonical_qs = {}
125+
local canonical_qs_i = 0
125126
for k, v in pairs(params.query) do
126-
canonical_qs[#canonical_qs+1] = ngx.unescape_uri(k) .. "=" .. ngx.unescape_uri(v)
127+
canonical_qs_i = canonical_qs_i + 1
128+
canonical_qs[canonical_qs_i] = ngx.unescape_uri(k) .. "=" .. ngx.unescape_uri(v)
127129
end
128130

129131
tab_sort(canonical_qs)
@@ -132,10 +134,12 @@ local function request_processor(conf, ctx, params)
132134
-- computing canonical and signed headers
133135

134136
local canonical_headers, signed_headers = {}, {}
137+
local signed_headers_i = 0
135138
for k, v in pairs(headers) do
136139
k = k:lower()
137140
if k ~= "connection" then
138-
signed_headers[#signed_headers+1] = k
141+
signed_headers_i = signed_headers_i + 1
142+
signed_headers[signed_headers_i] = k
139143
-- strip starting and trailing spaces including strip multiple spaces into single space
140144
canonical_headers[k] = str_strip(v)
141145
end

0 commit comments

Comments
 (0)