From 1334fc09bf1e6cd36b08c5ebfa1c654f67d570b6 Mon Sep 17 00:00:00 2001 From: Bluewhale1337 <295648290+Bluewhale1337@users.noreply.github.com> Date: Sat, 18 Jul 2026 12:27:51 +0200 Subject: [PATCH] perf: replace table.foreach with pairs loops to avoid GC spikes during combat --- HealBot_Action.lua | 8 ++++---- HealBot_View_Layout.lua | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/HealBot_Action.lua b/HealBot_Action.lua index 052a0c6..4d32195 100644 --- a/HealBot_Action.lua +++ b/HealBot_Action.lua @@ -22,9 +22,9 @@ function HealBot_ShouldHeal(unit) end function HealBot_Action_ShouldHealSome() - return table.foreach(HealBot_Action_HealButtons, function (index,button) + for index, button in pairs(HealBot_Action_HealButtons) do if (HealBot_ShouldHeal(button.unit)) then return button.unit; end - end); + end end function HealBot_MustHeal(unit) @@ -32,9 +32,9 @@ function HealBot_MustHeal(unit) end function HealBot_Action_MustHealSome() - return table.foreach(HealBot_Action_HealButtons, function (index,button) + for index, button in pairs(HealBot_Action_HealButtons) do if (HealBot_MustHeal(button.unit)) then return button.unit; end - end); + end end function HealBot_GetRezSpellForClass() diff --git a/HealBot_View_Layout.lua b/HealBot_View_Layout.lua index 9884ca8..40ef3c9 100644 --- a/HealBot_View_Layout.lua +++ b/HealBot_View_Layout.lua @@ -255,9 +255,9 @@ function HealBot_Action_EnableButton(button) end function HealBot_Action_EnableButtons() - table.foreach(HealBot_Action_HealButtons, function (index, button) - HealBot_Action_EnableButton(button); - end); + for index, button in pairs(HealBot_Action_HealButtons) do + HealBot_Action_EnableButton(button) + end end function HealBot_Action_RefreshButton(button) @@ -285,13 +285,13 @@ end function HealBot_Action_RefreshButtons(unit) if unit and HealBot_Action_UnitButtons[unit] then - table.foreach(HealBot_Action_UnitButtons[unit], function (index, button) - HealBot_Action_RefreshButton(button); - end); + for index, button in pairs(HealBot_Action_UnitButtons[unit]) do + HealBot_Action_RefreshButton(button) + end else - table.foreach(HealBot_Action_HealButtons, function (index, button) - HealBot_Action_RefreshButton(button); - end); + for index, button in pairs(HealBot_Action_HealButtons) do + HealBot_Action_RefreshButton(button) + end end end @@ -748,7 +748,7 @@ function HealBot_Action_PartyChanged() local i = 0; local z = 1; - table.foreach(HealBot_Action_HealButtons, function (index, button) + for index, button in pairs(HealBot_Action_HealButtons) do i = i + 1; local checked = false; local header; @@ -787,7 +787,7 @@ function HealBot_Action_PartyChanged() bar:SetScale(barScale); bar2:SetHeight(bheight); HealBot_Action_SetTexture(bar2, btexture); - end); + end if MaxOffsetY < OffsetY then MaxOffsetY = OffsetY; end