From ea9197c57166da67bd0499a33a4d6e3c06cc03f8 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Sun, 10 Jul 2022 12:21:17 +0200 Subject: [PATCH] table.deep_to_add: Don't emit empty subtables --- table.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/table.lua b/table.lua index d1ac960..bd04527 100644 --- a/table.lua +++ b/table.lua @@ -489,7 +489,10 @@ function deep_to_add(table, after_additions) local additions = {} for key, value in pairs(after_additions) do if type(table[key]) == "table" and type(value) == "table" then - additions[key] = deep_to_add(table[key], value) + local sub_additions = deep_to_add(table[key], value) + if next(sub_additions) ~= nil then + additions[key] = sub_additions + end elseif table[key] ~= value then additions[key] = value end