加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

F#与C#的“不安全”块具有相同的语法

发布时间:2020-12-15 04:28:02 所属栏目:百科 来源:网络整理
导读:许多阵列边界检查会降低速度,这对2D阵列尤其如此.有没有办法在F#中编写不安全的代码块? 解决方法 我不是一个 F#程序员,但据我看来,它似乎没有 unsafe关键字. 您可以通过将2D数组转换为一维数组来获得性能提升. Advice 5: Until we get this right,I would s
许多阵列边界检查会降低速度,这对2D阵列尤其如此.有没有办法在F#中编写不安全的代码块?

解决方法

我不是一个 F#程序员,但据我看来,它似乎没有 unsafe关键字.

您可以通过将2D数组转换为一维数组来获得性能提升.

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读