From 250757c1a17604ab7522216c3282783eb1cccd67 Mon Sep 17 00:00:00 2001 From: WenMing Date: Wed, 9 Jan 2019 02:28:37 +0800 Subject: [PATCH] perf(pdk) optimize kong.ip module by tracking a table size via a local From #4169 --- kong/pdk/ip.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kong/pdk/ip.lua b/kong/pdk/ip.lua index bec7ea3895c9..23449068efb6 100644 --- a/kong/pdk/ip.lua +++ b/kong/pdk/ip.lua @@ -41,11 +41,13 @@ local function new(self) -- supports. Also as an optimization we will only compile trusted ips if -- Kong is not run with the default 0.0.0.0/0, ::/0 aka trust all ip -- addresses settings. + local idx = 1 for i = 1, n_ips do local address = ips[i] if ip.valid(address) then - table.insert(trusted_ips, address) + trusted_ips[idx] = address + idx = idx + 1 if address == "0.0.0.0/0" then trust_all_ipv4 = true