S
Silvers11
Guest
Hello!
I wonder if 2 Dimensional "ReadOnlySpan<byte>" is supported and if that exists how I would declare such variable in "function2()"
I am trying to write this line in function2 where I try to assign a 2D array to the ReadOnlySpan<byte> but the ReadOnlySpan is has only a single dimension in this case.
I tried this but the compiler didn't allow this:
ReadOnlySpan<ReadOnlySpan<byte>> input2 = new ReadOnlySpan<ReadOnlySpan<byte>>();
To mention is that I micro-optimizing and using unsafe code and Vector(SIMD instructions) where ReadOnlySpan has been put in my examples. It seems that this is used for critical performance code. So if it is possible to use only the ReadOnlySpan in a 2 dimensional way.
Thank you!
void function1()
{
byte[] v1 = new byte[100];
ReadOnlySpan<byte> input = v1;
callfromfunction1(input);
}
private unsafe static void callfromfunction1(ReadOnlySpan<byte> v1)
{
}
void function2()
{
byte[,] v1 = new byte[100, 100];
ReadOnlySpan<byte> input = v1; //Is it possible to assign an 2D array to a 2D "ReadOnlySpan<byte>" in some way?
callfromfunction2(input);
}
private unsafe static void callfromfunction2(ReadOnlySpan<byte> v1)
{
}
Continue reading...
I wonder if 2 Dimensional "ReadOnlySpan<byte>" is supported and if that exists how I would declare such variable in "function2()"
I am trying to write this line in function2 where I try to assign a 2D array to the ReadOnlySpan<byte> but the ReadOnlySpan is has only a single dimension in this case.
I tried this but the compiler didn't allow this:
ReadOnlySpan<ReadOnlySpan<byte>> input2 = new ReadOnlySpan<ReadOnlySpan<byte>>();
To mention is that I micro-optimizing and using unsafe code and Vector(SIMD instructions) where ReadOnlySpan has been put in my examples. It seems that this is used for critical performance code. So if it is possible to use only the ReadOnlySpan in a 2 dimensional way.
Thank you!
void function1()
{
byte[] v1 = new byte[100];
ReadOnlySpan<byte> input = v1;
callfromfunction1(input);
}
private unsafe static void callfromfunction1(ReadOnlySpan<byte> v1)
{
}
void function2()
{
byte[,] v1 = new byte[100, 100];
ReadOnlySpan<byte> input = v1; //Is it possible to assign an 2D array to a 2D "ReadOnlySpan<byte>" in some way?
callfromfunction2(input);
}
private unsafe static void callfromfunction2(ReadOnlySpan<byte> v1)
{
}
Continue reading...