Browse Source

nit: minor refactor to switch expression (#1561)

tags/2.3.0
Joe4evr GitHub 4 years ago
parent
commit
42826df5e4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 10 deletions
  1. +7
    -10
      src/Discord.Net.Core/Utils/Comparers.cs

+ 7
- 10
src/Discord.Net.Core/Utils/Comparers.cs View File

@@ -41,16 +41,13 @@ namespace Discord
{
public override bool Equals(TEntity x, TEntity y)
{
bool xNull = x == null;
bool yNull = y == null;

if (xNull && yNull)
return true;

if (xNull ^ yNull)
return false;

return x.Id.Equals(y.Id);
return (x, y) switch
{
(null, null) => true,
(null, _) => false,
(_, null) => false,
var (l, r) => l.Id.Equals(r.Id)
};
}

public override int GetHashCode(TEntity obj)


Loading…
Cancel
Save