Is there any reasons to not use "mmap" to read files?
sarn
sarn at theartofmachinery.com
Tue Feb 8 21:37:29 UTC 2022
On Sunday, 6 February 2022 at 09:40:48 UTC, rempas wrote:
> This should have probably been posted in the "Learn" section
> but I thought that it is an advanced topic so maybe people
> other than me may learn something too. So here we go!
>
> I'm planning to make a change to my program to use "mmap" to
> the contents of a file rather than "fgetc". This is because I
> learned that "mmap" can do it faster. The thing is, are there
> any problems that can occur when using "mmap"? I need to know
> now because changing this means changing the design of the
> program and this is not something pleasant to do so I want to
> be sure that I won't have to change back in the future (where
> the project will be even bigger).
One reason to use read/write based I/O by default is that it's
more versatile. It's kind of like an input range versus a random
access in Phobos.
```
// Could not map file /dev/stdin (Invalid argument)
auto f = new MmFile("/dev/stdin");
```
More information about the Digitalmars-d
mailing list