An easy phobos i/o bug to fix

starcanopy starcanopy at protonmail.com
Wed Jul 29 03:08:43 UTC 2020


On Wednesday, 29 July 2020 at 02:18:44 UTC, Steven Schveighoffer 
wrote:
> On 7/28/20 7:24 PM, starcanopy wrote:
>> On Monday, 27 July 2020 at 15:19:44 UTC, Steven Schveighoffer 
>> wrote:
>>> If anyone is using windows and std.stdio.File.rawWrite, it's 
>>> insanely slow. And it's an easy fix. See 
>>> https://issues.dlang.org/show_bug.cgi?id=7033
>>>
>>> I don't use Windows, so I probably won't get around to fixing 
>>> this. But ping me if you make a PR, I will review it.
>>>
>> 
>> So, upon opening a File, save the mode into a field, and only 
>> execute the current behavior iff the mode isn't binary?
>
> Almost! I was thinking to store the current mode, and then only 
> change the mode when needed, including the required flush.
>
> This way, subsequent rawWrite calls are less expensive, even if 
> it was open originally for text mode.
>
> -Steve

Looks like the contents of the Windows' version needs to be put 
into an if statement if I'm correctly following you.

version (Windows)
{
     import std.algorithm: canFind;

     /* currMode is a member of File
     I'd imagine, unless the value being assigned to currMode is 
normalized, canFind or something similar would be preferable over 
exhaustive checking. */
     if (!currMode.canFind("b"))
     {
         // current behavior
     }
}

// write


More information about the Digitalmars-d mailing list