Skip to content

Commit

Permalink
style(pdk/log): simplify buffer:put with vararg-style
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Jun 24, 2024
1 parent 1be5d78 commit a6ca4ff
Showing 1 changed file with 15 additions and 15 deletions.
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

0 comments on commit a6ca4ff

Please sign in to comment.