Skip to content

Instantly share code, notes, and snippets.

@aensidhe
Created July 17, 2018 20:38
Show Gist options
  • Save aensidhe/c86f679c4aa313ab748de965f0c19575 to your computer and use it in GitHub Desktop.
Save aensidhe/c86f679c4aa313ab748de965f0c19575 to your computer and use it in GitHub Desktop.
Nice code
public static bool TryReadExtension(ReadOnlySpan<byte> buffer, out byte type, out IMemoryOwner<byte> extension, out int readSize)
{
extension = null;
return TryReadExtensionHeader(buffer, out type, out var length, out readSize)
&& length <= int.MaxValue
&& TryReadExtension(buffer, (int) length, ref extension, ref readSize);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment