about summary refs log tree commit diff stats
path: root/source_undo.lua
diff options
context:
space:
mode:
Diffstat (limited to 'source_undo.lua')
-rw-r--r--source_undo.lua8
1 files changed, 4 insertions, 4 deletions
diff --git a/source_undo.lua b/source_undo.lua
index d91fecd..772e5da 100644
--- a/source_undo.lua
+++ b/source_undo.lua
@@ -84,12 +84,12 @@ end
 -- https://stackoverflow.com/questions/640642/how-do-you-copy-a-lua-table-by-value/26367080#26367080
 function deepcopy(obj, seen)
   if type(obj) ~= 'table' then return obj end
-  if seen and seen[obj] then return seen[obj] end
-  local s = seen or {}
+  seen = seen or {}
+  if seen[obj] then return seen[obj] end
   local result = setmetatable({}, getmetatable(obj))
-  s[obj] = result
+  seen[obj] = result
   for k,v in pairs(obj) do
-    result[deepcopy(k, s)] = deepcopy(v, s)
+    result[deepcopy(k, seen)] = deepcopy(v, seen)
   end
   return result
 end