C# · 12月 23, 2021


许多阵列边界检查会降低速度,这对2D阵列尤其如此.有没有办法在F#中编写不安全的代码块?解决方法 我不是一个 F#程序员,但据我看来,它似乎没有 unsafe关键字.


Advice 5: Until we get this right,I
would suggest that .NET users do what
many C++ numerical programmers do:
write a class to implement your
n-dimensional array. This would be
represented as a 1-dimensional array,
and the relevant accessors would
convert n indices into 1 via
appropriate multiplications. We
almost certainly wouldn’t eliminate
the bounds check into the 1-d array,
but at least we’d only do one check!

Array Bounds Check Elimination in the CLR