Quote:Original post by DrGUIQuote:Original post by RipTorn...
That looks good but will it be much slower than the unsafe version?
That I cannot say.
I'm not sure if GetBytes makes a copy of the byte data or just returns a wrapper Array on the float.
Logically, the JIT should optimize it down so it's just as fast.
But then again I don't know anything about the way the JIT optimises. If it wasn't summer I could probably ask one of the guys I know working on Rotor's optimiser... But for now it's just a guess. Sorry.
I don't think there would be any other way to do it in safe code however.
So I guess it's just a question of if you want it safe or not.
You could do what I do an have #define USE_UNSAFE_CODE then appropriate #if #else #endif blocks.
profile it with nprof and see I guess.
my experience with .net so far has mostly shown that things you expect to be slow end up being very fast, and things you expect to be fast end up slow :) so you never know, it might be faster than the unsafe version ;) - or the unsafe version may just compile to the same code anyway.