Skip to content

Commit

Permalink
Use object.ReferenceEquals for reference type equality comparison (si…
Browse files Browse the repository at this point in the history
  • Loading branch information
paulomorgado authored Jan 7, 2025
1 parent 3429dfd commit d7833a6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/core/SIP/SIPEndPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public override bool Equals(object obj)

public static bool operator ==(SIPEndPoint endPoint1, SIPEndPoint endPoint2)
{
if ((object)endPoint1 == null && (object)endPoint2 == null)
if (object.ReferenceEquals(endPoint1, endPoint2))
{
return true;
}
Expand Down
5 changes: 3 additions & 2 deletions src/core/SIP/SIPParameters.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Filename: SIPParameters.cs
//
// Description: SIP parameters as used in Contact, To, From and Via SIP headers.
Expand All @@ -16,6 +16,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Runtime.Serialization;
using Microsoft.Extensions.Logging;
using SIPSorcery.Sys;
Expand Down Expand Up @@ -337,7 +338,7 @@ public override bool Equals(object obj)
/// </summary>
public static bool operator ==(SIPParameters x, SIPParameters y)
{
if (x is null && y is null)
if (object.ReferenceEquals(x, y))
{
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/SIP/SIPURI.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Filename: SIPURI.cs
//
// Description: SIP URI.
Expand Down Expand Up @@ -605,7 +605,7 @@ public override bool Equals(object obj)

public static bool operator ==(SIPURI uri1, SIPURI uri2)
{
if (uri1 is null && uri2 is null)
if (object.ReferenceEquals(uri1, uri2))
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/net/STUN/STUNUri.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public override bool Equals(object obj)

public static bool operator ==(STUNUri uri1, STUNUri uri2)
{
if (uri1 is null && uri2 is null)
if (object.ReferenceEquals(uri1, uri2))
{
return true;
}
Expand Down

0 comments on commit d7833a6

Please sign in to comment.