From 358857850623a4846f9d6f7fe3499b4d3df446f6 Mon Sep 17 00:00:00 2001 From: Rainrider Date: Thu, 21 Apr 2022 22:22:41 +0200 Subject: [PATCH] refactor: perform table comparisson in a single call --- oUF_Dispellable.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/oUF_Dispellable.lua b/oUF_Dispellable.lua index 28125cd..22fde0f 100644 --- a/oUF_Dispellable.lua +++ b/oUF_Dispellable.lua @@ -354,12 +354,19 @@ local function ToggleElement(enable) end end -local function AreTablesEqual(a, b) +-- shallow comparison of primitive key/value types +local function TablesMatch(a, b) for k, v in next, a do if b[k] ~= v then return false end end + for k, v in next, b do + if a[k] ~= v then + return false + end + end + return true end @@ -376,10 +383,7 @@ local function UpdateDispels() end if next(available) then - local areEqual = AreTablesEqual(available, canDispel) - areEqual = areEqual and AreTablesEqual(canDispel, available) - - if not areEqual then + if not TablesMatch(available, canDispel) then wipe(canDispel) for debuffType in next, available do canDispel[debuffType] = available[debuffType]