Unsafe Pointer iteration and Bitmap - why is UInt64 faster?

倖福魔咒の 提交于 2019-12-04 10:11:46

This is a technique known as loop unrolling. The main performance benefit should come from reducing the branching overhead.

As a side note, you could speed it up a bit by using a bitmask:

*((UInt64 *)pointer) &= 0xFFFFFF00FFFFFF00ul;

It's not the incrementing the pointer that is slower, but reading from memory. With 32-bit units, you're doing twice as many reads.

You should find it faster again if you write once instead of twice in the 64-bit version.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!