From aa10e27560fd0f921a41debbde3bdc9c2d018e5f Mon Sep 17 00:00:00 2001 From: chronolaw Date: Wed, 9 Aug 2023 18:11:46 +0800 Subject: [PATCH] Revert "perf(router): iterate routes with for loop (#11111)" This reverts commit e8173ca30b902202e289e93ab34cf40a907fd3d6. --- kong/router/atc.lua | 8 ++------ kong/router/utils.lua | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/kong/router/atc.lua b/kong/router/atc.lua index fc8bd6a64f4a..eb30f5976a33 100644 --- a/kong/router/atc.lua +++ b/kong/router/atc.lua @@ -187,9 +187,7 @@ local function new_from_scratch(routes, get_exp_and_priority) local new_updated_at = 0 - for i = 1, routes_n do - local r = routes[i] - + for _, r in ipairs(routes) do local route = r.route local route_id = route.id @@ -249,9 +247,7 @@ local function new_from_previous(routes, get_exp_and_priority, old_router) local new_updated_at = 0 -- create or update routes - for i = 1, #routes do - local r = routes[i] - + for _, r in ipairs(routes) do local route = r.route local route_id = route.id diff --git a/kong/router/utils.lua b/kong/router/utils.lua index db0d9985e456..5b9844d55d5b 100644 --- a/kong/router/utils.lua +++ b/kong/router/utils.lua @@ -288,8 +288,8 @@ do local v0 = 0 local v1 = 0 - for i = 1, #routes do - local r = routes[i].route + for _, route in ipairs(routes) do + local r = route.route local paths_t = r.paths or empty_table local headers_t = r.headers or empty_table