@@ -21,6 +21,9 @@ namespace Xtensive.Core
2121 IComparable < Pair < TFirst , TSecond > > ,
2222 IEquatable < Pair < TFirst , TSecond > >
2323 {
24+ private static readonly AdvancedComparerStruct < TFirst > FirstComparer = AdvancedComparerStruct < TFirst > . System ;
25+ private static readonly AdvancedComparerStruct < TSecond > SecondComparer = AdvancedComparerStruct < TSecond > . System ;
26+
2427 /// <summary>
2528 /// A first value.
2629 /// </summary>
@@ -33,33 +36,25 @@ namespace Xtensive.Core
3336 #region IComparable<...>, IEquatable<...> methods
3437
3538 /// <inheritdoc/>
36- public bool Equals ( Pair < TFirst , TSecond > other )
37- {
38- if ( ! AdvancedComparerStruct < TFirst > . System . Equals ( First , other . First ) )
39- return false ;
40- return AdvancedComparerStruct < TSecond > . System . Equals ( Second , other . Second ) ;
41- }
39+ public bool Equals ( Pair < TFirst , TSecond > other ) =>
40+ FirstComparer . Equals ( First , other . First ) && SecondComparer . Equals ( Second , other . Second ) ;
4241
4342 /// <inheritdoc/>
4443 public int CompareTo ( Pair < TFirst , TSecond > other )
4544 {
46- int result = AdvancedComparerStruct < TFirst > . System . Compare ( First , other . First ) ;
47- if ( result != 0 )
48- return result ;
49- return AdvancedComparerStruct < TSecond > . System . Compare ( Second , other . Second ) ;
45+ int result = FirstComparer . Compare ( First , other . First ) ;
46+ return result != 0
47+ ? result
48+ : SecondComparer . Compare ( Second , other . Second ) ;
5049 }
5150
5251 #endregion
5352
5453 #region Equals, GetHashCode, ==, !=
5554
5655 /// <inheritdoc/>
57- public override bool Equals ( object obj )
58- {
59- if ( obj . GetType ( ) != typeof ( Pair < TFirst , TSecond > ) )
60- return false ;
61- return Equals ( ( Pair < TFirst , TSecond > ) obj ) ;
62- }
56+ public override bool Equals ( object obj ) =>
57+ obj is Pair < TFirst , TSecond > other && Equals ( other ) ;
6358
6459 /// <inheritdoc/>
6560 public override int GetHashCode ( )
0 commit comments