Skip to content

Commit

Permalink
avoid some memory allocations when generating the navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
adelikat committed Mar 24, 2024
1 parent 70823c4 commit 2ae2dad
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions TASVideos/TagHelpers/NavbarTagHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,22 @@ protected bool IsActive()
switch (Activate)
{
case "Home" when page == "/Index":
case "Movies" when new[] { "Publications", "Submissions", "UserFiles" }.Contains(pageGroup):
case "Articles" when new[] { "ArticleIndex", "Game Resources", "EmulatorResources" }.Contains(viewActiveTab):
case "Admin" when new[] { "Roles", "Users", "Permissions" }.Contains(pageGroup):
case "Movies" when MoviesGroup.Contains(pageGroup):
case "Articles" when ArticlesGroup.Contains(viewActiveTab):
case "Admin" when AdminGroup.Contains(pageGroup):
case "Register" when page == "/Account/Register":
case "Login" when page == "/Account/Login":
case "Wiki" when new[] { "SandBox", "RecentChanges", "WikiOrphans", "TODO", "System", "DeletedPages" }.Contains(viewActiveTab):
case "Wiki" when WikiGroup.Contains(viewActiveTab):
return true;
}

// Wiki Razor Pages that are not the general wiki page action
return string.IsNullOrWhiteSpace(viewActiveTab)
&& Activate == "Wiki" && pageGroup == "Wiki";
}

private static readonly string[] MoviesGroup = ["Publications", "Submissions", "UserFiles"];
private static readonly string[] ArticlesGroup = ["ArticleIndex", "Game Resources", "EmulatorResources"];
private static readonly string[] AdminGroup = ["Roles", "Users", "Permissions"];
private static readonly string[] WikiGroup = ["SandBox", "RecentChanges", "WikiOrphans", "TODO", "System", "DeletedPages"];
}

0 comments on commit 2ae2dad

Please sign in to comment.