c# - F# 是否具有与 C#'s "unsafe"block 等效的语法

标签 c# .net arrays f#

大量的数组边界检查会降低速度,尤其是二维数组。有没有办法在 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

关于c# - F# 是否具有与 C#'s "unsafe"block 等效的语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3650067/

相关文章:

c# - .NET - 如何正确设置函数的 Azure 服务总线队列/主题

c# - WCF 服务 - 向后兼容性问题

C++ - 字符数组以某种方式初始化为错误的大小

arrays - 将字符串转换为 PSCustomObjects 数组

c# - C# 中的 LPT 端口

c# - 从静态类访问 HttpContextBase 对象

c# - IEnumerable FirstOrEmpty 扩展

C#/C++ pInvoke 技巧

c# - 嵌套结构作为类中的成员

javascript - 为什么 JavaScript 有以下几种连线行为?