Skip to content

Commit

Permalink
perf(router/atc): move assert to unlikely path
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Feb 26, 2024
1 parent 7e31f08 commit 0e91054
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions kong/router/fields.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 0e91054

Please sign in to comment.