@@ -97,8 +97,8 @@ public static bool TryParse(string range, out SlotRange value)
97
97
/// <param name="other">The other slot range to compare to.</param>
98
98
public int CompareTo ( SlotRange other )
99
99
{
100
- int delta = ( int ) this . from - ( int ) other . from ;
101
- return delta == 0 ? ( int ) this . to - ( int ) other . to : delta ;
100
+ int delta = ( int ) from - ( int ) other . from ;
101
+ return delta == 0 ? ( int ) to - ( int ) other . to : delta ;
102
102
}
103
103
104
104
/// <summary>
@@ -161,7 +161,7 @@ internal ClusterConfiguration(ServerSelectionStrategy serverSelectionStrategy, s
161
161
{
162
162
// Beware: Any exception thrown here will wreak silent havoc like inability to connect to cluster nodes or non returning calls
163
163
this . serverSelectionStrategy = serverSelectionStrategy ;
164
- this . Origin = origin ;
164
+ Origin = origin ;
165
165
using ( var reader = new StringReader ( nodes ) )
166
166
{
167
167
string line ;
@@ -178,7 +178,7 @@ internal ClusterConfiguration(ServerSelectionStrategy serverSelectionStrategy, s
178
178
// make sure that things like clusterConfiguration[clusterConfiguration.Origin]
179
179
// will work as expected.
180
180
if ( node . IsMyself )
181
- this . Origin = node . EndPoint ;
181
+ Origin = node . EndPoint ;
182
182
183
183
if ( nodeLookup . ContainsKey ( node . EndPoint ) )
184
184
{
@@ -286,7 +286,7 @@ internal ClusterNode(ClusterConfiguration configuration, string raw, EndPoint or
286
286
{
287
287
// https://redis.io/commands/cluster-nodes
288
288
this . configuration = configuration ;
289
- this . Raw = raw ;
289
+ Raw = raw ;
290
290
var parts = raw . Split ( StringSplits . Space ) ;
291
291
292
292
var flags = parts [ 2 ] . Split ( StringSplits . Comma ) ;
@@ -319,8 +319,7 @@ internal ClusterNode(ClusterConfiguration configuration, string raw, EndPoint or
319
319
{
320
320
if ( SlotRange . TryParse ( parts [ i ] , out SlotRange range ) )
321
321
{
322
- if ( slots == null ) slots = new List < SlotRange > ( parts . Length - i ) ;
323
- slots . Add ( range ) ;
322
+ ( slots ?? ( slots = new List < SlotRange > ( parts . Length - i ) ) ) . Add ( range ) ;
324
323
}
325
324
}
326
325
Slots = slots ? . AsReadOnly ( ) ?? NoSlots ;
@@ -338,10 +337,9 @@ public IList<ClusterNode> Children
338
337
List < ClusterNode > nodes = null ;
339
338
foreach ( var node in configuration . Nodes )
340
339
{
341
- if ( node . ParentNodeId == this . NodeId )
340
+ if ( node . ParentNodeId == NodeId )
342
341
{
343
- if ( nodes == null ) nodes = new List < ClusterNode > ( ) ;
344
- nodes . Add ( node ) ;
342
+ ( nodes ?? ( nodes = new List < ClusterNode > ( ) ) ) . Add ( node ) ;
345
343
}
346
344
}
347
345
children = nodes ? . AsReadOnly ( ) ?? NoNodes ;
@@ -416,14 +414,14 @@ public int CompareTo(ClusterNode other)
416
414
{
417
415
if ( other == null ) return - 1 ;
418
416
419
- if ( this . IsSlave != other . IsSlave ) return IsSlave ? 1 : - 1 ; // masters first
417
+ if ( IsSlave != other . IsSlave ) return IsSlave ? 1 : - 1 ; // masters first
420
418
421
419
if ( IsSlave ) // both slaves? compare by parent, so we get masters A, B, C and then slaves of A, B, C
422
420
{
423
- int i = string . CompareOrdinal ( this . ParentNodeId , other . ParentNodeId ) ;
421
+ int i = string . CompareOrdinal ( ParentNodeId , other . ParentNodeId ) ;
424
422
if ( i != 0 ) return i ;
425
423
}
426
- return string . CompareOrdinal ( this . NodeId , other . NodeId ) ;
424
+ return string . CompareOrdinal ( NodeId , other . NodeId ) ;
427
425
}
428
426
429
427
/// <summary>
0 commit comments