File tree 1 file changed +12
-4
lines changed
src/Elastic.Clients.Elasticsearch/Core/Infer/Metric
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 4
4
5
5
using System ;
6
6
using System . Collections . Generic ;
7
- using System . Linq ;
8
7
using Elastic . Transport ;
9
8
10
9
namespace Elastic . Clients . Elasticsearch ;
@@ -53,8 +52,8 @@ public bool Equals(Metrics other)
53
52
{
54
53
if ( other is null ) return false ;
55
54
56
- // Equality is true when the metrics names in both instances are equal, regardless of their order in the set .
57
- return Values . OrderBy ( t => t ) . SequenceEqual ( other . Values . OrderBy ( t => t ) ) ;
55
+ // Equality is true when both instances have the same metric names .
56
+ return Values . SetEquals ( other . Values ) ;
58
57
}
59
58
60
59
string IUrlParameter . GetString ( ITransportConfiguration settings ) => GetString ( ) ;
@@ -71,7 +70,16 @@ private string GetString()
71
70
}
72
71
73
72
/// <inheritdoc />
74
- public override int GetHashCode ( ) => Values != null ? Values . GetHashCode ( ) : 0 ;
73
+ public override int GetHashCode ( )
74
+ {
75
+ // Lifting the minimal target framework to .NET Standard 2.1
76
+ // would be the best solution ever due to the HashCode type.
77
+ var hashCode = 0 ;
78
+ foreach ( var metric in Values )
79
+ hashCode = ( hashCode * 397 ) ^ metric . GetHashCode ( ) ;
80
+
81
+ return hashCode ;
82
+ }
75
83
76
84
public static bool operator == ( Metrics left , Metrics right ) => Equals ( left , right ) ;
77
85
public static bool operator != ( Metrics left , Metrics right ) => ! Equals ( left , right ) ;
You can’t perform that action at this time.
0 commit comments