top | item 47211457

(no title)

SvenL | 6 hours ago

I think you don’t need to be unsafe, they have normal API for it.

https://learn.microsoft.com/en-us/dotnet/standard/io/memory-...

discuss

order

Const-me|5 hours ago

Indeed, but these normal APIs have runtime costs for bounds checking. For some use cases, unsafe can be better. For instance, last time I used a memory-mapped file was for a large immutable Bloom filter. I knew the file should be exactly 4GB, validated that in the constructor, then when testing 12 bits from random location of the mapped file on each query, I opted for unsafe codes.