Add various optimizations and cleanups (#1114)
* Change all Select(... as ...) to OfType
* Add changes according to 194a8aa427
This commit is contained in:
@@ -97,7 +97,7 @@ namespace Discord.WebSocket
|
||||
if (id == Recipient.Id)
|
||||
return Recipient;
|
||||
else if (id == Discord.CurrentUser.Id)
|
||||
return Discord.CurrentUser as SocketSelfUser;
|
||||
return Discord.CurrentUser;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ namespace Discord.WebSocket
|
||||
public class SocketGroupChannel : SocketChannel, IGroupChannel, ISocketPrivateChannel, ISocketMessageChannel, ISocketAudioChannel
|
||||
{
|
||||
private readonly MessageCache _messages;
|
||||
private readonly ConcurrentDictionary<ulong, SocketVoiceState> _voiceStates;
|
||||
|
||||
private string _iconId;
|
||||
private ConcurrentDictionary<ulong, SocketGroupUser> _users;
|
||||
private ConcurrentDictionary<ulong, SocketVoiceState> _voiceStates;
|
||||
|
||||
public string Name { get; private set; }
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace Discord.WebSocket
|
||||
internal SocketGroupUser GetOrAddUser(UserModel model)
|
||||
{
|
||||
if (_users.TryGetValue(model.Id, out SocketGroupUser user))
|
||||
return user as SocketGroupUser;
|
||||
return user;
|
||||
else
|
||||
{
|
||||
var privateUser = SocketGroupUser.Create(this, Discord.State, model);
|
||||
@@ -143,7 +143,7 @@ namespace Discord.WebSocket
|
||||
if (_users.TryRemove(id, out SocketGroupUser user))
|
||||
{
|
||||
user.GlobalUser.RemoveRef(Discord);
|
||||
return user as SocketGroupUser;
|
||||
return user;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user