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

@@ -334,8 +334,7 @@ public static class FullTOC
default: default:
{ {
if(descriptor.POINT >= 0x01 && if(descriptor.POINT is >= 0x01 and <= 0x63)
descriptor.POINT <= 0x63)
if(descriptor.ADR == 4) if(descriptor.ADR == 4)
sb.AppendFormat("Video track {3} starts at: {0:D2}:{1:D2}:{2:D2}", sb.AppendFormat("Video track {3} starts at: {0:D2}:{1:D2}:{2:D2}",
descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME, descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME,
@@ -525,8 +524,7 @@ public static class FullTOC
default: default:
{ {
if(descriptor.POINT >= 0x01 && if(descriptor.POINT is >= 0x01 and <= 0x40)
descriptor.POINT <= 0x40)
{ {
sb. sb.
AppendFormat("Start time for interval that should be skipped: {0:D2}:{1:D2}:{2:D2}", AppendFormat("Start time for interval that should be skipped: {0:D2}:{1:D2}:{2:D2}",

View File

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

View File

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