There is a well-known efficiency for comparing two byte-arrays in .Net by importing the memcmp
function from msvcrt.dll
, as described here.
Is there an equivalent library import in mono? Would it need to be different when running mono on linux or on windows? Or is there another fast byte array comparison technique that works well in mono? I'm looking for something better than just iterating over the arrays in c#.
Update
Based on Matt Patenaude's comment, I think this might work well:
#if __MonoCS__
[DllImport("c", CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)]
#endif
public static extern int memcmp(byte[] b1, byte[] b2, UIntPtr count);
But I have not yet tried it. I've never done p/invoke on mono before. I'm using the signature recommended on pinvoke.net. Is this going to be compatible?
Looking for a Mono-focused answer. Thanks.