Skip to content

Commit

Permalink
Issue1: Avoid repeated calculation of SumOfRolesCount (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlang42 authored Dec 11, 2023
1 parent 667dfc5 commit 955defb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Desktop/ViewModels/ShowRootOrSectionView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,11 @@ public string[] CountErrorBackgroundColors
{
get
{
uint[]? sum_of_roles_count = null;
var colors = new string[castGroups.Length];
for (var i = 0; i < colors.Length; i++)
if (CountByGroups[i].Count is uint required_count
&& SumOfRolesCount[i] != required_count)
&& (sum_of_roles_count ??= SumOfRolesCount)[i] != required_count) // avoid repeated calculation of SumOfRolesCount, but also only calculate if needed
colors[i] = HighlightError.ERROR_COLOR;
else
colors[i] = HighlightError.TEXTBOX_COLOR;
Expand Down

0 comments on commit 955defb

Please sign in to comment.