Skip to content

Commit

Permalink
Optimize main render loop
Browse files Browse the repository at this point in the history
Low-hanging fruit optimization: the main "foreach" loop was changed
to a "for" loop, to avoid copying all player structs.
  • Loading branch information
louistakepillz committed Sep 24, 2019
1 parent 3fa3719 commit b7c0165
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Classes/FriendlyHUDInteraction.uc
Original file line number Diff line number Diff line change
Expand Up @@ -1245,12 1245,12 @@ function bool IsPRIRenderable(FriendlyHUDReplicationInfo RepInfo, int RepIndex)
function DrawTeamHealthBars(Canvas Canvas)
{
local FriendlyHUDReplicationInfo RepInfo;
local PRIEntry CurrentPRIEntry;
local KFPlayerReplicationInfo KFPRI;
local ASDisplayInfo StatsDI, GearDI;
local float CurrentItemPosX, CurrentItemPosY;
local int ItemCount, Column, Row;
local PlayerItemInfo ItemInfo;
local int I;

if (HUD.HUDMovie == None || HUD.HUDMovie.PlayerStatusContainer == None || HUD.HUDMovie.PlayerBackpackContainer == None)
{
Expand Down Expand Up @@ -1337,14 1337,15 @@ function DrawTeamHealthBars(Canvas Canvas)
if (SortedKFPRIArray.Length == 0) return;

ItemCount = 0;
foreach SortedKFPRIArray(CurrentPRIEntry)

for (I = 0; I < SortedKFPRIArray.Length; I )
{
RepInfo = CurrentPRIEntry.RepInfo;
KFPRI = CurrentPRIEntry.KFPRI;
RepInfo = SortedKFPRIArray[I].RepInfo;
KFPRI = SortedKFPRIArray[I].KFPRI;

if (!ManualModeActive && HUDConfig.MaxItemCount >= 0 && ItemCount >= HUDConfig.MaxItemCount) break;

if (!IsPRIRenderable(RepInfo, CurrentPRIEntry.RepIndex)) continue;
if (!IsPRIRenderable(RepInfo, SortedKFPRIArray[I].RepIndex)) continue;

// Layout: row first
if (HUDConfig.Flow == 1)
Expand All @@ -1370,10 1371,10 @@ function DrawTeamHealthBars(Canvas Canvas)
// Left/right layouts flow up
: (R.ScreenPosY - R.TotalItemHeight * (HUDConfig.ReverseY ? (HudConfig.ItemsPerColumn - 1 - Row) : Row));

ItemInfo.KFPH = RepInfo.KFPHArray[CurrentPRIEntry.RepIndex];
ItemInfo.KFPH = RepInfo.KFPHArray[SortedKFPRIArray[I].RepIndex];
ItemInfo.KFPRI = KFPRI;
ItemInfo.RepInfo = RepInfo;
ItemInfo.RepIndex = CurrentPRIEntry.RepIndex;
ItemInfo.RepIndex = SortedKFPRIArray[I].RepIndex;

if (DrawHealthBarItem(Canvas, ItemInfo, CurrentItemPosX, CurrentItemPosY))
{
Expand Down

0 comments on commit b7c0165

Please sign in to comment.