Fastest way of reading and writing binary

前端 未结 4 757
渐次进展
渐次进展 2021-01-31 06:42

I\'m currently optimizing an application, one of the operations that is done very often is reading and writing binary. I need 2 types of functions:

Set(byte[] ta         


        
4条回答
  •  攒了一身酷
    2021-01-31 06:53

    Pointers are the way to go. Pinning objects with the fixed keyword is extremely cheap, and you avoid the overhead of calling functions like WriteInt32 and BlockCopy. For a "generic solution" you can simply use void* and use your own memcpy (since you're dealing with small amounts of data). However pointers do not work with true generics.

提交回复
热议问题