Builtin auth handler: Speed up file writing (#7252)
authorSmallJoker <SmallJoker@users.noreply.github.com>
Thu, 19 Apr 2018 16:36:10 +0000 (18:36 +0200)
committerGitHub <noreply@github.com>
Thu, 19 Apr 2018 16:36:10 +0000 (18:36 +0200)
builtin/game/auth.lua

index 3d4d6b1996bc1762d2dae1b513e931dfa28ba50e..ad2f35a138e659519733656038a8e89f80cd9b4b 100644 (file)
@@ -42,13 +42,13 @@ local function save_auth_file()
                assert(type(stuff.privileges) == "table")
                assert(stuff.last_login == nil or type(stuff.last_login) == "number")
        end
-       local content = ""
+       local content = {}
        for name, stuff in pairs(auth_table) do
                local priv_string = core.privs_to_string(stuff.privileges)
                local parts = {name, stuff.password, priv_string, stuff.last_login or ""}
-               content = content .. table.concat(parts, ":") .. "\n"
+               content[#content + 1] = table.concat(parts, ":")
        end
-       if not core.safe_file_write(auth_file_path, content) then
+       if not core.safe_file_write(auth_file_path, table.concat(content, "\n")) then
                error(auth_file_path.." could not be written to")
        end
 end