Skip to content

Commit

Permalink
perf(dns): reduce table creation
Browse files Browse the repository at this point in the history
  • Loading branch information
chobits committed Jul 11, 2024
1 parent 77fba30 commit f0d6e2a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion kong/dns/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ local type = type
local ipairs = ipairs
local tonumber = tonumber
local math_random = math.random
local table_clear = require("table.clear")
local table_insert = table.insert
local table_remove = table.remove

Expand Down Expand Up @@ -257,7 +258,8 @@ do
for _, answer in ipairs(answers) do
if answer.priority < lowest_priority then
lowest_priority = answer.priority
l = { answer }
table_clear(l)
l[1] = answer

elseif answer.priority == lowest_priority then
table_insert(l, answer)
Expand Down

0 comments on commit f0d6e2a

Please sign in to comment.