Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style(pdk/log): simplify buffer:put with vararg-style #13200

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions kong/pdk/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,29 +152,29 @@ local serializers = {
end,

[2] = function(buf, sep, to_string, ...)
buf:put(to_string((select(1, ...)))):put(sep)
:put(to_string((select(2, ...))))
buf:put(to_string((select(1, ...))), sep,
to_string((select(2, ...))))
end,

[3] = function(buf, sep, to_string, ...)
buf:put(to_string((select(1, ...)))):put(sep)
:put(to_string((select(2, ...)))):put(sep)
:put(to_string((select(3, ...))))
buf:put(to_string((select(1, ...))), sep,
to_string((select(2, ...))), sep,
to_string((select(3, ...))))
end,

[4] = function(buf, sep, to_string, ...)
buf:put(to_string((select(1, ...)))):put(sep)
:put(to_string((select(2, ...)))):put(sep)
:put(to_string((select(3, ...)))):put(sep)
:put(to_string((select(4, ...))))
buf:put(to_string((select(1, ...))), sep,
to_string((select(2, ...))), sep,
to_string((select(3, ...))), sep,
to_string((select(4, ...))))
end,

[5] = function(buf, sep, to_string, ...)
buf:put(to_string((select(1, ...)))):put(sep)
:put(to_string((select(2, ...)))):put(sep)
:put(to_string((select(3, ...)))):put(sep)
:put(to_string((select(4, ...)))):put(sep)
:put(to_string((select(5, ...))))
buf:put(to_string((select(1, ...))), sep,
to_string((select(2, ...))), sep,
to_string((select(3, ...))), sep,
to_string((select(4, ...))), sep,
to_string((select(5, ...))))
end,
}

Expand Down Expand Up @@ -334,7 +334,7 @@ local function gen_log_func(lvl_const, imm_buf, to_string, stack_level, sep)

else
for i = 1, n - 1 do
variadic_buf:put(to_string((select(i, ...)))):put(sep or "")
variadic_buf:put(to_string((select(i, ...))), sep or "")
end
variadic_buf:put(to_string((select(n, ...))))
end
Expand Down
Loading