randomIO, std.file, core.stdc.stdio
Charles Hixson via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jul 27 11:44:13 PDT 2016
On 07/27/2016 06:46 AM, Rene Zwanenburg via Digitalmars-d-learn wrote:
> On Wednesday, 27 July 2016 at 02:20:57 UTC, Charles Hixson wrote:
>> O, dear. It was sounding like such an excellent approach until this
>> last paragraph, but growing the file is going to be one of the common
>> operations. (Certainly at first.) (...)
>> So I'm probably better off sticking to using a seek based i/o system.
>
> Not necessarily. The usual approach is to over-allocate your file so
> you don't need to grow it that often. This is the exact same strategy
> used by D's dynamic arrays and grow-able array-backed lists in other
> languages - the difference between list length and capacity.
>
> There is no built-in support for this in std.mmfile afaik. But it's
> not hard to do yourself.
>
Well, that would mean I didn't need to reopen the file so often, but
that sure wouldn't mean I wouldn't need to re-open the file. And it
would add considerable complexity. Possibly that would be an optimal
approach once the data was mainly collected, but I won't want to
re-write this bit at that point.
More information about the Digitalmars-d-learn
mailing list