From 8a14f04734fe78b13e204e6dd347a40e8b2c6482 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Wed, 12 May 2021 20:53:44 +0200 Subject: [PATCH] Lua log file: Fix short notations --- persistence.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/persistence.lua b/persistence.lua index d7db0e9..08d1204 100644 --- a/persistence.lua +++ b/persistence.lua @@ -80,13 +80,12 @@ function lua_log_file:_dump(value, is_key) if _type == "number" then return ("%.17g"):format(value) end - if self.references[value] then - return "R[" .. self.references[value] .. "]" + local reference = self.references[value] + if reference then + return "R[" .. reference .."]" end - self.reference_count = self.reference_count + 1 - local reference = self.reference_count + reference = self.reference_count + 1 local key = "R[" .. reference .."]" - self.references[value] = reference local formatted if _type == "string" then if is_key and value:len() <= key:len() and value:match"[%a_][%a%d_]*" then @@ -114,6 +113,8 @@ function lua_log_file:_dump(value, is_key) else error("unsupported type: " .. _type) end + self.reference_count = reference + self.references[value] = reference self:log(key .. "=" .. formatted) return key end