1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-01 17:38:41 +00:00

Faster insertion into table

This commit is contained in:
Rui914 2016-03-07 00:53:45 +09:00 committed by paramat
parent 75db0543f3
commit 24e8b0ac1e
13 changed files with 48 additions and 45 deletions

View file

@ -116,7 +116,7 @@ core.register_chatcommand("help", {
local cmds = {}
for cmd, def in pairs(core.chatcommands) do
if core.check_player_privs(name, def.privs) then
table.insert(cmds, cmd)
cmds[#cmds + 1] = cmd
end
end
table.sort(cmds)
@ -127,7 +127,7 @@ core.register_chatcommand("help", {
local cmds = {}
for cmd, def in pairs(core.chatcommands) do
if core.check_player_privs(name, def.privs) then
table.insert(cmds, format_help_line(cmd, def))
cmds[#cmds + 1] = format_help_line(cmd, def)
end
end
table.sort(cmds)
@ -135,7 +135,7 @@ core.register_chatcommand("help", {
elseif param == "privs" then
local privs = {}
for priv, def in pairs(core.registered_privileges) do
table.insert(privs, priv .. ": " .. def.description)
privs[#privs + 1] = priv .. ": " .. def.description
end
table.sort(privs)
return true, "Available privileges:\n"..table.concat(privs, "\n")