Skip to content

Commit f96c524

Browse files
committed
Apply a hashset equals for performance
1 parent 5d46b50 commit f96c524

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

Build/CommonAssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
//
1616
// You can specify all the values or you can default the Revision and Build Numbers
1717
// by using the '*' as shown below:
18-
[assembly: AssemblyVersion("3.7.1")]
19-
[assembly: AssemblyFileVersion("3.7.1")]
18+
[assembly: AssemblyVersion("3.7.2")]
19+
[assembly: AssemblyFileVersion("3.7.2")]
2020
//[assembly: AssemblyInformationalVersion("2.5-filters")]

Griddly/Views/Shared/Griddly/Griddly.cshtml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,20 @@
120120

121121
if (param != null)
122122
{
123-
// TODO: perhaps use hashset for performance or a scrambled equals algo?
124-
// https://stackoverflow.com/a/3670008/65611
125-
// https://stackoverflow.com/a/3670089/65611
126-
return Griddly.Mvc.GriddlyExtensions.GetFormattedValueByType(x.Value)?.OrderBy(y => y).SequenceEqual(Griddly.Mvc.GriddlyExtensions.GetFormattedValueByType(param).OrderBy(y => y)) ?? false;
123+
// se hashset for performance https://stackoverflow.com/a/3670008/65611
124+
// 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
125+
//return Griddly.Mvc.GriddlyExtensions.GetFormattedValueByType(x.Value)?.OrderBy(y => y).SequenceEqual(Griddly.Mvc.GriddlyExtensions.GetFormattedValueByType(param).OrderBy(y => y)) ?? false;
126+
127+
var vals = Griddly.Mvc.GriddlyExtensions.GetFormattedValueByType(x.Value);
128+
129+
if (vals == null)
130+
{
131+
return false;
132+
}
133+
134+
var parms = Griddly.Mvc.GriddlyExtensions.GetFormattedValueByType(param);
135+
136+
return new HashSet<string>(vals).SetEquals(new HashSet<string>(parms));
127137
}
128138

129139
return false;

0 commit comments

Comments
 (0)