Skip to content

Commit

Permalink
Apply a hashset equals for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
ithielnor committed Feb 20, 2024
1 parent 5d46b50 commit f96c524
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Build/CommonAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("3.7.1")]
[assembly: AssemblyFileVersion("3.7.1")]
[assembly: AssemblyVersion("3.7.2")]
[assembly: AssemblyFileVersion("3.7.2")]
//[assembly: AssemblyInformationalVersion("2.5-filters")]
18 changes: 14 additions & 4 deletions Griddly/Views/Shared/Griddly/Griddly.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,20 @@

if (param != null)
{
// TODO: perhaps use hashset for performance or a scrambled equals algo?
// https://stackoverflow.com/a/3670008/65611
// https://stackoverflow.com/a/3670089/65611
return Griddly.Mvc.GriddlyExtensions.GetFormattedValueByType(x.Value)?.OrderBy(y => y).SequenceEqual(Griddly.Mvc.GriddlyExtensions.GetFormattedValueByType(param).OrderBy(y => y)) ?? false;
// se hashset for performance https://stackoverflow.com/a/3670008/65611
// if duplicate values are desirable (I can't think of why) we can switch to a a scrambled equals: https://stackoverflow.com/a/3670089/65611
//return Griddly.Mvc.GriddlyExtensions.GetFormattedValueByType(x.Value)?.OrderBy(y => y).SequenceEqual(Griddly.Mvc.GriddlyExtensions.GetFormattedValueByType(param).OrderBy(y => y)) ?? false;
var vals = Griddly.Mvc.GriddlyExtensions.GetFormattedValueByType(x.Value);

if (vals == null)
{
return false;
}

var parms = Griddly.Mvc.GriddlyExtensions.GetFormattedValueByType(param);

return new HashSet<string>(vals).SetEquals(new HashSet<string>(parms));
}

return false;
Expand Down

0 comments on commit f96c524

Please sign in to comment.