Merge null/pattern checks into complex pattern.

This commit is contained in:
2022-11-13 20:46:23 +00:00
parent e727683929
commit 83612d6084
3 changed files with 9 additions and 22 deletions

View File

@@ -2214,24 +2214,19 @@ public static class EVPD
break;
}
if(page.Component != null &&
page.Component.Length > 0)
if(page.Component is { Length: > 0 })
sb.AppendFormat("\tComponent: {0}", StringHandlers.CToString(page.Component)).AppendLine();
if(page.Version != null &&
page.Version.Length > 0)
if(page.Version is { Length: > 0 })
sb.AppendFormat("\tVersion: {0}", StringHandlers.CToString(page.Version)).AppendLine();
if(page.Date != null &&
page.Date.Length > 0)
if(page.Date is { Length: > 0 })
sb.AppendFormat("\tDate: {0}", StringHandlers.CToString(page.Date)).AppendLine();
if(page.Variant != null &&
page.Variant.Length > 0)
if(page.Variant is { Length: > 0 })
sb.AppendFormat("\tVariant: {0}", StringHandlers.CToString(page.Variant)).AppendLine();
if(page.Copyright != null &&
page.Copyright.Length > 0)
if(page.Copyright is { Length: > 0 })
sb.AppendFormat("\tCopyright: {0}", StringHandlers.CToString(page.Copyright)).AppendLine();
return sb.ToString();

View File

@@ -44,10 +44,7 @@ public static class DensitySupport
{
public static DensitySupportHeader? DecodeDensity(byte[] response)
{
if(response == null)
return null;
if(response.Length <= 56)
if(response is not { Length: > 56 })
return null;
var responseLen = (ushort)((response[0] << 8) + response[1] + 2);
@@ -147,10 +144,7 @@ public static class DensitySupport
public static MediaTypeSupportHeader? DecodeMediumType(byte[] response)
{
if(response == null)
return null;
if(response.Length <= 60)
if(response is not { Length: > 60 })
return null;
var responseLen = (ushort)((response[0] << 8) + response[1] + 2);