We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e9666c3 commit 63a375eCopy full SHA for 63a375e
src/libraries/Common/src/System/Security/Cryptography/Helpers.cs
@@ -45,12 +45,12 @@ internal static partial class Helpers
45
[return: NotNullIfNotNull(nameof(src))]
46
public static byte[]? CloneByteArray(this byte[]? src)
47
{
48
- if (src == null)
+ return src switch
49
50
- return null;
51
- }
52
-
53
- return (byte[])(src.Clone());
+ null => null,
+ { Length: 0 } => src,
+ _ => (byte[])src.Clone(),
+ };
54
}
55
56
internal static bool TryCopyToDestination(this ReadOnlySpan<byte> source, Span<byte> destination, out int bytesWritten)
0 commit comments