Skip to content

Commit

Permalink
qol, Improve equals
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusfriedman committed Nov 15, 2023
1 parent cdb9509 commit 74ebe3e
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 18 deletions.
4 changes: 1 addition & 3 deletions Rtp/Rtcp/RtcpHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -602,9 +602,7 @@ public override bool Equals(object obj)
{
if(System.Object.ReferenceEquals(this, obj)) return true;

if (false.Equals((obj is RtcpHeader))) return false;

return Equals(obj as RtcpHeader);
return obj is RtcpHeader header && Equals(header);
}

#endregion
Expand Down
4 changes: 1 addition & 3 deletions Rtp/Rtcp/RtcpPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,9 +1011,7 @@ public override bool Equals(object obj)
{
if (System.Object.ReferenceEquals(this, obj)) return true;

if ((obj is RtcpPacket) is false) return false;

return Equals(obj as RtcpPacket);
return obj is RtcpPacket rtcp && Equals(rtcp);
}

//Packet equals...
Expand Down
4 changes: 1 addition & 3 deletions Rtp/RtpHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -602,9 +602,7 @@ public override bool Equals(object obj)
{
if (System.Object.ReferenceEquals(this, obj)) return true;

if (false.Equals((obj is RtpHeader))) return false;

return Equals(obj as RtpHeader);
return obj is RtpHeader header && Equals(header);
}

#endregion
Expand Down
4 changes: 1 addition & 3 deletions Rtp/RtpPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -909,9 +909,7 @@ public override bool Equals(object obj)
{
if (System.Object.ReferenceEquals(this, obj)) return true;

if (false.Equals((obj is RtpPacket))) return false;

return Equals(obj as RtpPacket);
return obj is RtpPacket rtp && Equals(rtp);
}

//Packet equals...
Expand Down
4 changes: 1 addition & 3 deletions Rtsp/RtspMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -934,9 +934,7 @@ public override bool Equals(object obj)
{
if (System.Object.ReferenceEquals(this, obj)) return true;

if (false.Equals((obj is RtspMessage))) return false;

RtspMessage other = obj as RtspMessage;
if (obj is not RtspMessage other) return false;

//Fast path doesn't show true equality.
//other.Created != Created
Expand Down
4 changes: 1 addition & 3 deletions Sdp/SessionDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1192,9 +1192,7 @@ public override bool Equals(object obj)
//System.Object
if (object.ReferenceEquals(this, obj)) return true;

if ((obj is SessionDescription) is false) return false;

return Equals(obj as SessionDescription);
return obj is SessionDescription sdp && Equals(sdp);
}

/// <summary>
Expand Down

0 comments on commit 74ebe3e

Please sign in to comment.