I have some data containing jagged arrays of uints.
The data must be logged fast, so i was thinking of using stream.Write
using (var stream = File.Open(Folder + @"\"+Filename, FileMode.OpenOrCreate))
{
// uint[][] RawData = new Uint [9000][]
foreach(uint[] LogRow in RawData)
{
stream.Write(LogRow, 0, 300);
}
}
}
However Stream.write accepts only bytes[ ]
Might it be possible, to simply get the pointer offset of LogRow
Then since a a uint is 32bits use a count of 300*4
And do a write the uInt[ ] Logrow as a Byte buffer ?.
Maybe width unsafe conversion ?
int * ByteOffset = &LogRow;
//... ?? its a start
// but it doesnt give the LogRow as Byte[]
// not sure the best way to continou
//
---Update note ---
This code needs to work with video data buffers, so it has to be as fast as possible with no overhead of conversions, or extra threads, or safety checks, boundary checks. In the old days people used to think more about speed as we had less candy in our coding shop. There are a few areas left in today's coding needs, where speed is still "the" major requirement. This is such a question. Don't assume that I get more speed by improving other areas of my code as you've not seen the rest, neither its a constructive discussion to this topic.
Basically what i want is having uint LogRow[] , be available as byte[] without conversions. Think of it as computer memory that i don't want to alter, just take the uint[] as if it was a byte[], should be possible to calculate the offset and length and assign it to a byte[] array,.. something that would go easy in c++ or assembler, the extra difficultly is its jagged array of uint[]. As a reminder a major difference width VB is that C# does have unsafe options, though using them is an Art.
The one liner I wrote below is a cast conversion (The C# compiler will do boundary check on casting), but I write it down just showing that i'm aware of what conversion is, and that i'm not looking for conversion answers, who add extra instructions.
byte[] objectCast = (byte[])(object)LogRow;
How to do that?
unsafecode.