Skip to content

Commit

Permalink
Equals -> is
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusfriedman committed Nov 15, 2023
1 parent 98cf12d commit 5286dd5
Show file tree
Hide file tree
Showing 24 changed files with 122 additions and 122 deletions.
2 changes: 1 addition & 1 deletion Common/Classes/SegmentStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public int CopyTo(byte[] destination, int offset, int count)

foreach (Common.MemorySegment ms in Segments)
{
if (ms.Count.Equals(Common.Binary.Zero)) continue;
if (ms.Count is Common.Binary.Zero) continue;

min = Binary.Min(count, ms.Count);

Expand Down
10 changes: 5 additions & 5 deletions Common/Extensions/EncodingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static bool ReadDelimitedDataFrom(this System.Text.Encoding encoding, byt

int max;

if (count.Equals(Common.Binary.Zero) || Common.Extensions.Array.ArrayExtensions.IsNullOrEmpty(buffer, out max))
if (count is Common.Binary.Zero || Common.Extensions.Array.ArrayExtensions.IsNullOrEmpty(buffer, out max))
{
result = null;

Expand All @@ -121,7 +121,7 @@ public static bool ReadDelimitedDataFrom(this System.Text.Encoding encoding, byt
max -= offset;

//The smaller of the two, max and count
if ((count = Common.Binary.Min(ref max, ref count)).Equals(0)) return false;
if ((count = Common.Binary.Min(ref max, ref count)) is 0) return false;

bool sawDelimit = false;

Expand Down Expand Up @@ -160,7 +160,7 @@ public static bool ReadDelimitedDataFrom(this System.Text.Encoding encoding, byt
#endif

//If there are not enough bytes to decode the char
if (justRead.Equals(Common.Binary.Zero))
if (justRead is Common.Binary.Zero)
{
break;
}
Expand Down Expand Up @@ -199,7 +199,7 @@ public static bool ReadDelimitedDataFrom(this System.Text.Encoding encoding, byt
return sawDelimit;
}

result = builder.Length.Equals(Common.Binary.Zero) ? string.Empty : builder.ToString();
result = builder.Length is Common.Binary.Zero ? string.Empty : builder.ToString();

//Take the amount of bytes in the string as what was read.
read = encoding.GetByteCount(result);
Expand Down Expand Up @@ -235,7 +235,7 @@ public static bool ReadDelimitedDataFrom(this System.Text.Encoding encoding, Sys

if (delimits == null) delimits = EmptyChar;

if (stream == null || false.Equals(stream.CanRead) || count.Equals(Common.Binary.Zero))
if (stream == null || false.Equals(stream.CanRead) || count is Common.Binary.Zero)
{
result = null;

Expand Down
2 changes: 1 addition & 1 deletion Common/Extensions/ExceptionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static bool InException
{
//See http://geekswithblogs.net/akraus1/archive/2008/04/08/121121.aspx
return System.Runtime.InteropServices.Marshal.GetExceptionPointers() == System.IntPtr.Zero &&
System.Runtime.InteropServices.Marshal.GetExceptionCode().Equals(Common.Binary.Zero) ? false : true;
System.Runtime.InteropServices.Marshal.GetExceptionCode() is Common.Binary.Zero ? false : true;
}
}

Expand Down
6 changes: 3 additions & 3 deletions Common/Extensions/SocketExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ public static bool IsTcpNotUrgent(System.Net.Sockets.Socket socket)
if (Common.Extensions.Array.ArrayExtensions.IsNullOrEmpty(value, out len) || len < Common.Binary.BytesPerInteger) return false;

//Read the 32 bits of the buffer in network byte order, return true if the value != 0
return false.Equals(Common.Binary.Read32(value, Common.Binary.BytesPerInteger, Media.Common.Binary.IsLittleEndian).Equals(0));
return false.Equals(Common.Binary.Read32(value, Common.Binary.BytesPerInteger, Media.Common.Binary.IsLittleEndian) is 0);
}

/// <summary>
Expand All @@ -816,7 +816,7 @@ public static bool IsTcpStandardUrgency(System.Net.Sockets.Socket socket, bool c
if (Common.Extensions.Array.ArrayExtensions.IsNullOrEmpty(value, out len) || len < Common.Binary.BytesPerInteger) return false;

//Read the 32 bits of the buffer in network byte order, return true if the value != 0
return false.Equals(Common.Binary.Read32(value, Common.Binary.BytesPerInteger, Media.Common.Binary.IsLittleEndian).Equals(0));
return false.Equals(Common.Binary.Read32(value, Common.Binary.BytesPerInteger, Media.Common.Binary.IsLittleEndian) is 0);
}

public static int GetTcpExpedited(System.Net.Sockets.Socket socket)
Expand Down Expand Up @@ -901,7 +901,7 @@ public static bool GetIsTcpOutOfBandInLine(System.Net.Sockets.Socket socket)
if (Common.Extensions.Array.ArrayExtensions.IsNullOrEmpty(value, out len) || len < Common.Binary.BytesPerInteger) return false;

//Read the 32 bits of the buffer in network byte order, return true if the value != 0
return false.Equals(Common.Binary.Read32(value, Common.Binary.BytesPerInteger, Media.Common.Binary.IsLittleEndian).Equals(0));
return false.Equals(Common.Binary.Read32(value, Common.Binary.BytesPerInteger, Media.Common.Binary.IsLittleEndian) is 0);
}

#endregion
Expand Down
14 changes: 7 additions & 7 deletions Common/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static byte[] HexStringToBytes(string str, int start = 0, int length = -1
//Dont check the results for overflow
unchecked
{
if (length.Equals(Common.Binary.Zero)) return null;
if (length is Common.Binary.Zero) return null;

if (length <= -1) length = str.Length;

Expand Down Expand Up @@ -230,7 +230,7 @@ public static string Substring(this string source, int startIndex, int count, st
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public static string[] SplitTrim(this string ex, string[] seperator, int count, System.StringSplitOptions options)
{
if (count.Equals(Common.Binary.Zero) || Common.Extensions.Array.ArrayExtensions.IsNullOrEmpty(seperator)) return new string[Common.Binary.Zero];
if (count is Common.Binary.Zero || Common.Extensions.Array.ArrayExtensions.IsNullOrEmpty(seperator)) return new string[Common.Binary.Zero];

string[] results = ex.Split(seperator, count, options);

Expand All @@ -242,7 +242,7 @@ public static string[] SplitTrim(this string ex, string[] seperator, int count,
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public static string[] SplitTrim(this string ex, char[] seperator, int count, System.StringSplitOptions options)
{
if (count.Equals(Common.Binary.Zero) || Common.Extensions.Array.ArrayExtensions.IsNullOrEmpty(seperator)) return new string[0];
if (count is Common.Binary.Zero || Common.Extensions.Array.ArrayExtensions.IsNullOrEmpty(seperator)) return new string[0];

string[] results = ex.Split(seperator, count, options);

Expand All @@ -254,7 +254,7 @@ public static string[] SplitTrim(this string ex, char[] seperator, int count, Sy
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public static string[] SplitTrimEnd(this string ex, string[] seperator, int count, System.StringSplitOptions options)
{
if (count.Equals(Common.Binary.Zero) || Common.Extensions.Array.ArrayExtensions.IsNullOrEmpty(seperator)) return new string[Common.Binary.Zero];
if (count is Common.Binary.Zero || Common.Extensions.Array.ArrayExtensions.IsNullOrEmpty(seperator)) return new string[Common.Binary.Zero];

string[] results = ex.Split(seperator, count, options);

Expand All @@ -266,7 +266,7 @@ public static string[] SplitTrimEnd(this string ex, string[] seperator, int coun
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public static string[] SplitTrimEnd(this string ex, char[] seperator, int count, System.StringSplitOptions options)
{
if (count.Equals(Common.Binary.Zero) || Common.Extensions.Array.ArrayExtensions.IsNullOrEmpty(seperator)) return new string[Common.Binary.Zero];
if (count is Common.Binary.Zero || Common.Extensions.Array.ArrayExtensions.IsNullOrEmpty(seperator)) return new string[Common.Binary.Zero];

string[] results = ex.Split(seperator, count, options);

Expand All @@ -278,7 +278,7 @@ public static string[] SplitTrimEnd(this string ex, char[] seperator, int count,
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public static string[] SplitTrimStart(this string ex, string[] seperator, int count, System.StringSplitOptions options)
{
if (count.Equals(Common.Binary.Zero) || Common.Extensions.Array.ArrayExtensions.IsNullOrEmpty(seperator)) return new string[Common.Binary.Zero];
if (count is Common.Binary.Zero || Common.Extensions.Array.ArrayExtensions.IsNullOrEmpty(seperator)) return new string[Common.Binary.Zero];

string[] results = ex.Split(seperator, count, options);

Expand All @@ -290,7 +290,7 @@ public static string[] SplitTrimStart(this string ex, string[] seperator, int co
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
public static string[] SplitTrimStart(this string ex, char[] seperator, int count, System.StringSplitOptions options)
{
if (count.Equals(Common.Binary.Zero) || Common.Extensions.Array.ArrayExtensions.IsNullOrEmpty(seperator)) return new string[Common.Binary.Zero];
if (count is Common.Binary.Zero || Common.Extensions.Array.ArrayExtensions.IsNullOrEmpty(seperator)) return new string[Common.Binary.Zero];

string[] results = ex.Split(seperator, count, options);

Expand Down
2 changes: 1 addition & 1 deletion Concepts/Classes/Arrays.cs
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ public bool IsEmpty
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
get
{
return m_Header.m_Length.Equals(Common.Binary.Zero);
return m_Header.m_Length is Common.Binary.Zero;
}
}

Expand Down
4 changes: 2 additions & 2 deletions Concepts/Classes/Threading/Pool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ public double Occupancy
{
get
{
if(Slots.Equals(0)) return -(Whole * m_Leases.Count);
else if (m_Leases.Count.Equals(0)) return -(Whole * Slots);
if(Slots is 0) return -(Whole * m_Leases.Count);
else if (m_Leases.Count is 0) return -(Whole * Slots);
return (m_Leases.Count / Slots) / Whole;
}
}
Expand Down
18 changes: 9 additions & 9 deletions Http/HttpMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ virtual protected bool ParseHeaders(bool force = false)
sawDelemit = Media.Common.Extensions.Encoding.EncodingExtensions.ReadDelimitedDataFrom(HeaderEncoding, buffer, m_EncodedLineEnds, position, remains, out rawLine, out justRead, true);

//There is not enough data in the buffer
if(justRead.Equals(0)) break;
if(justRead is 0) break;

//Check for the empty line
if (string.IsNullOrWhiteSpace(rawLine))
Expand Down Expand Up @@ -1629,7 +1629,7 @@ internal protected virtual bool ParseBody(out int remaining, bool force = false)
//Todo, should only check this after determining whats available...

//Empty body or no ContentLength
if (m_ContentLength.Equals(0))
if (m_ContentLength is 0)
{
//m_Body = string.Empty;

Expand All @@ -1642,7 +1642,7 @@ internal protected virtual bool ParseBody(out int remaining, bool force = false)
//Calculate how much data remains based on the ContentLength
//remaining = m_ContentLength - m_Body.Length;

if (available.Equals(0)) return false;
if (available is 0) return false;

//Get the decoder to use for the body
Encoding decoder = ParseContentEncoding(false, FallbackToDefaultEncoding);
Expand All @@ -1655,7 +1655,7 @@ internal protected virtual bool ParseBody(out int remaining, bool force = false)

remaining = ParseContentLength() ? m_ContentLength - existingBodySize : available;

if (remaining.Equals(0)) return true;
if (remaining is 0) return true;

//Get the array of the memory stream
byte[] buffer = m_Buffer.GetBuffer();
Expand Down Expand Up @@ -1735,7 +1735,7 @@ internal protected virtual bool ParseBody(out int remaining, bool force = false)
m_Buffer.Seek(m_HeaderOffset = (int)lastPos, System.IO.SeekOrigin.Begin);
return true;
}
else if (chunkSize.Equals(0))
else if (chunkSize is 0)
{
//Trailer

Expand Down Expand Up @@ -1855,7 +1855,7 @@ internal string GetHeaderValue(string name, out string actualName)
actualName = null;
if (IsDisposed && false == IsPersistent || string.IsNullOrWhiteSpace(name)) return null;
foreach (string headerName in GetHeaders())
if (string.Compare(name, headerName, true).Equals(0)) //headerName.Equals(name, StringComparison.OrdinalIgnoreCase);
if (string.Compare(name, headerName, true) is 0) //headerName.Equals(name, StringComparison.OrdinalIgnoreCase);
{
actualName = headerName;

Expand All @@ -1871,7 +1871,7 @@ internal string GetEntityHeaderValue(string name, out string actualName)
actualName = null;
if (IsDisposed && false == IsPersistent || string.IsNullOrWhiteSpace(name)) return null;
foreach (string headerName in GetEntityHeaders())
if (string.Compare(name, headerName, true).Equals(0)) //headerName.Equals(name, StringComparison.OrdinalIgnoreCase);
if (string.Compare(name, headerName, true) is 0) //headerName.Equals(name, StringComparison.OrdinalIgnoreCase);
{
actualName = headerName;

Expand Down Expand Up @@ -2589,7 +2589,7 @@ public bool Equals(HttpMessage other)
&&
other.GetHeaders().All(ContainsHeader)
&&
string.Compare(other.m_Body, m_Body, false).Equals(0);
string.Compare(other.m_Body, m_Body, false) is 0;
//&&
//other.Length == Length;
}
Expand Down Expand Up @@ -2796,7 +2796,7 @@ int ParseChunk(ref int offset, int length) //out string extensions
}

// /r or /n by itself, if there is another byte consume it.
if (read.Equals(1) && sawDelemit && length > 1)
if (read is 1 && sawDelemit && length > 1)
{
++offset;

Expand Down
4 changes: 2 additions & 2 deletions Rtp/Rtcp/RtcpPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ public IEnumerable<byte> RtcpData
{
get
{
if (IsDisposed || Payload.Count.Equals(0)) return Media.Common.MemorySegment.Empty;
if (IsDisposed || Payload.Count is 0) return Media.Common.MemorySegment.Empty;

//return Payload.Take(Payload.Count - PaddingOctets);

Expand All @@ -701,7 +701,7 @@ public IEnumerable<byte> PaddingData
{
get
{
if (IsDisposed || Padding is false || IsComplete is false || Payload.Count.Equals(0)) return Media.Common.MemorySegment.Empty;
if (IsDisposed || Padding is false || IsComplete is false || Payload.Count is 0) return Media.Common.MemorySegment.Empty;

//return Payload.Skip(Payload.Count - PaddingOctets);

Expand Down
2 changes: 1 addition & 1 deletion Rtp/RtpClient.Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public static RtpClient FromSessionDescription(Sdp.SessionDescription sessionDes
byte lastChannel = 0;

//Todo, check for session level ssrc
//if (remoteSsrc.Equals(0))
//if (remoteSsrc is 0)
//{
// //Sdp.SessionDescriptionLine ssrcLine = sessionDescription.SsrcGroupLine; // SsrcLine @ the session level could imply Group
//}
Expand Down
Loading

0 comments on commit 5286dd5

Please sign in to comment.