Пример #1
0
 public static void CopyTo(this IPythonBuffer buffer, Span <byte> dest)
 {
     if (buffer.IsCContiguous())
     {
         buffer.AsReadOnlySpan().CopyTo(dest);
     }
     else
     {
         int i = 0;
         foreach (byte b in buffer.EnumerateBytes())
         {
             dest[i++] = b;
         }
     }
 }
Пример #2
0
 public static byte[] ToArray(this IPythonBuffer buffer)
 {
     if (buffer.IsCContiguous())
     {
         return(buffer.AsReadOnlySpan().ToArray());
     }
     else
     {
         var bytes = new byte[buffer.NumBytes()];
         int i     = 0;
         foreach (byte b in buffer.EnumerateBytes())
         {
             bytes[i++] = b;
         }
         return(bytes);
     }
 }