digitalmars.D - two questions (issues?) about phobos/std/mmfile.d
I'm checking file: https://github.com/dlang/phobos/blob/master/std/mmfile.d and found two questions (issues?) I don't understand, can someone explain? 1) This ctor: https://github.com/dlang/phobos/blob/master/std/mmfile.d#L79 version (linux) this(File file, Mode mode = Mode.read, ulong size = 0, void* address = null, size_t window = 0) scope is not doc-ed: https://dlang.org/phobos/std_mmfile.html and there is a version (Posix) implementation inside the doc-ed ctor: https://github.com/dlang/phobos/blob/master/std/mmfile.d#L275 There is some code duplication of these two implementation, so is the version (linux) needed at all? or it's some dead legacy code that should be deleted together with this: https://github.com/dlang/phobos/blob/master/std/mmfile.d#L87 2) in ensureMapped() why the requested mmap length are 3x window (2x is enough, since the start offset of the mmap must be multiples of pagesize): https://github.com/dlang/phobos/blob/master/std/mmfile.d#L556 ``` map(window*(block-1),3*window); // should this be?: map(window*(block), 2*window); ``` and https://github.com/dlang/phobos/blob/master/std/mmfile.d#L582 ``` map(window*(iblock-1),cast(size_t)(window*(jblock-iblock+3))); // should this be?: map(window*(iblock), cast(size_t)(window*(jblock-iblock+2))); ``` So the mapped buffer size is consistent of 2x window? Thanks.
Oct 13 2022
On Friday, 14 October 2022 at 00:30:55 UTC, mw wrote:2) in ensureMapped() why the requested mmap length are 3x window (2x is enough, since the start offset of the mmap must be multiples of pagesize):...https://github.com/dlang/phobos/blob/master/std/mmfile.d#L582 ``` map(window*(iblock-1),cast(size_t)(window*(jblock-iblock+3))); // should this be?: map(window*(iblock), cast(size_t)(window*(jblock-iblock+2))); ``` So the mapped buffer size is consistent of 2x window?and in ensureMapped(ulong i, ulong j), enforce(j - i <= window)? otherwise, what's the point of allowing user pass in `window` in the ctor, if it's not honored?
Oct 13 2022