Skip to content

Commit

Permalink
Minor deletion optimization in resource monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
tr4wzified committed Dec 22, 2024
1 parent 16f2bd5 commit 4628e4b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Wabbajack.App.Wpf/Models/ResourceMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,15 @@ private void Elapsed()
var now = DateTime.Now;
foreach (var resource in _resources)
{
foreach (var job in resource.Jobs.Where(j => j.Current > 0))
foreach (var job in resource.Jobs)
{
used.Add(job.ID);
// Delete
if(job.Current <= 0)
{
l.Remove(job.ID);
continue;
}

var tsk = l.Lookup(job.ID);
var jobProgress = job.Size == 0 ? Percent.Zero : Percent.FactoryPutInRange(job.Current, (long)job.Size);
// Update
Expand All @@ -93,10 +99,6 @@ private void Elapsed()
}
}
}

// Delete
foreach (var itm in l.Items.Where(v => !used.Contains(v.ID)))
l.Remove(itm);
});
_lastMeasuredDateTime = DateTime.Now;
}
Expand Down

0 comments on commit 4628e4b

Please sign in to comment.