From 0e91054f84aa5d3f53c2f04601967a5da1e08444 Mon Sep 17 00:00:00 2001 From: chronolaw Date: Wed, 31 Jan 2024 07:50:28 +0800 Subject: [PATCH] perf(router/atc): move assert to unlikely path --- kong/router/fields.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kong/router/fields.lua b/kong/router/fields.lua index 8bcdd7fbcb75..d975ce465c84 100644 --- a/kong/router/fields.lua +++ b/kong/router/fields.lua @@ -197,8 +197,10 @@ else -- stream end -- is_http --- stream subsystem need not to generate func -local get_field_accessor = function(funcs, field) end +-- stream subsystem needs not to generate func +local function get_field_accessor(funcs, field) + error("unknown router matching schema field: " .. field) +end if is_http then @@ -359,7 +361,8 @@ if is_http then return f end -- if field:sub(1, HTTP_SEGMENTS_PREFIX_LEN) - -- others return nil + -- others are error + error("unknown router matching schema field: " .. field) end end -- is_http @@ -451,8 +454,6 @@ function _M:get_value(field, params, ctx) local func = FIELDS_FUNCS[field] or get_field_accessor(self.funcs, field) - assert(func, "unknown router matching schema field: " .. field) - return func(params, ctx) end