Skip to content

Commit

Permalink
avoid some double casts (#1347)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Feb 15, 2024
1 parent bee89a7 commit 3f0a4ce
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Humanizer/Bytes/ByteSize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ public override bool Equals(object value)
}

ByteSize other;
if (value is ByteSize)
if (value is ByteSize size)
{
other = (ByteSize)value;
other = size;
}
else
{
Expand All @@ -359,12 +359,12 @@ public int CompareTo(object obj)
return 1;
}

if (!(obj is ByteSize))
if (obj is ByteSize size)
{
throw new ArgumentException("Object is not a ByteSize");
return CompareTo(size);
}

return CompareTo((ByteSize)obj);
throw new ArgumentException("Object is not a ByteSize");
}

public int CompareTo(ByteSize other)
Expand Down

0 comments on commit 3f0a4ce

Please sign in to comment.