readText with added null-terminator that enables sentinel-based search
Marco Leise via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Aug 9 02:21:26 PDT 2017
Am Tue, 08 Aug 2017 20:48:39 +0000
schrieb Nordlöw <per.nordlow at gmail.com>:
> Has anybody written a wrapper around `std.file.readText` (or
> similar) that appends a final zero-byte terminator in order to
> realize sentinel-based search in textual parsers.
What do you mean by similar? There are many ways to load a file
into memory before appending \0. In fast.json I used a memory
mapped file. On some OSs you can read past the end of such
mappings safely to generate extra \0 bytes. 16 zero-bytes is a
good amount if you want to use the SSE4.2 string instruction.
https://github.com/mleise/fast/blob/master/source/fast/json.d#L1464
--
Marco
More information about the Digitalmars-d-learn
mailing list