gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 17:41:02 27 4
gpt4 key购买 nike

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

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com