File tree Expand file tree Collapse file tree 2 files changed +26
-20
lines changed
osu.Game/Online/Multiplayer/MatchTypes/Matchmaking Expand file tree Collapse file tree 2 files changed +26
-20
lines changed Original file line number Diff line number Diff line change @@ -25,23 +25,26 @@ public class MatchmakingRoundList : IEnumerable<MatchmakingRound>
2525 /// Creates or retrieves the score for the given round.
2626 /// </summary>
2727 /// <param name="round">The round.</param>
28- public MatchmakingRound this [ int round ]
29- {
30- get
31- {
32- if ( RoundsDictionary . TryGetValue ( round , out MatchmakingRound ? score ) )
33- return score ;
34-
35- return RoundsDictionary [ round ] = new MatchmakingRound { Round = round } ;
36- }
37- }
28+ public MatchmakingRound this [ int round ] => GetOrAdd ( round ) ;
3829
3930 /// <summary>
4031 /// The total number of rounds.
4132 /// </summary>
4233 [ IgnoreMember ]
4334 public int Count => RoundsDictionary . Count ;
4435
36+ /// <summary>
37+ /// Retrieves or adds a <see cref="MatchmakingRound"/> entry to this list.
38+ /// </summary>
39+ /// <param name="round">The round.</param>
40+ public MatchmakingRound GetOrAdd ( int round )
41+ {
42+ if ( RoundsDictionary . TryGetValue ( round , out MatchmakingRound ? score ) )
43+ return score ;
44+
45+ return RoundsDictionary [ round ] = new MatchmakingRound { Round = round } ;
46+ }
47+
4548 public IEnumerator < MatchmakingRound > GetEnumerator ( ) => RoundsDictionary . Values . GetEnumerator ( ) ;
4649
4750 IEnumerator IEnumerable . GetEnumerator ( ) => GetEnumerator ( ) ;
Original file line number Diff line number Diff line change @@ -25,23 +25,26 @@ public class MatchmakingUserList : IEnumerable<MatchmakingUser>
2525 /// Creates or retrieves the user for the given id.
2626 /// </summary>
2727 /// <param name="userId">The user id.</param>
28- public MatchmakingUser this [ int userId ]
29- {
30- get
31- {
32- if ( UserDictionary . TryGetValue ( userId , out MatchmakingUser ? user ) )
33- return user ;
34-
35- return UserDictionary [ userId ] = new MatchmakingUser { UserId = userId } ;
36- }
37- }
28+ public MatchmakingUser this [ int userId ] => GetOrAdd ( userId ) ;
3829
3930 /// <summary>
4031 /// The total number of users.
4132 /// </summary>
4233 [ IgnoreMember ]
4334 public int Count => UserDictionary . Count ;
4435
36+ /// <summary>
37+ /// Retrieves or adds a <see cref="MatchmakingUser"/> entry to this list.
38+ /// </summary>
39+ /// <param name="userId">The user ID.</param>
40+ public MatchmakingUser GetOrAdd ( int userId )
41+ {
42+ if ( UserDictionary . TryGetValue ( userId , out MatchmakingUser ? user ) )
43+ return user ;
44+
45+ return UserDictionary [ userId ] = new MatchmakingUser { UserId = userId } ;
46+ }
47+
4548 public IEnumerator < MatchmakingUser > GetEnumerator ( ) => UserDictionary . Values . GetEnumerator ( ) ;
4649
4750 IEnumerator IEnumerable . GetEnumerator ( ) => GetEnumerator ( ) ;
You can’t perform that action at this time.
0 commit comments