Skip to content

Commit

Permalink
use compound statements (#1435)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Feb 22, 2024
1 parent 97e3519 commit cb66add
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
10 changes: 3 additions & 7 deletions src/Humanizer/Bytes/ByteSize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ public override string ToString() =>

public string ToString(IFormatProvider provider)
{
if (provider == null)
provider = CultureInfo.CurrentCulture;
provider ??= CultureInfo.CurrentCulture;

return string.Format(provider, "{0:0.##} {1}", LargestWholeNumberValue, GetLargestWholeNumberSymbol(provider));
}
Expand All @@ -209,11 +208,8 @@ public string ToString(string format, IFormatProvider provider) =>

string ToString(string format, IFormatProvider provider, bool toSymbol)
{
if (format == null)
format = "G";

if (provider == null)
provider = CultureInfo.CurrentCulture;
format ??= "G";
provider ??= CultureInfo.CurrentCulture;

if (format == "G")
format = "0.##";
Expand Down
5 changes: 1 addition & 4 deletions src/Humanizer/Truncation/FixedNumberOfCharactersTruncator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ public string Truncate(string value, int length, string truncationString, Trunca
return value;
}

if (truncationString == null)
{
truncationString = string.Empty;
}
truncationString ??= string.Empty;

if (truncationString.Length > length)
{
Expand Down

0 comments on commit cb66add

Please sign in to comment.