digitalmars.D.learn - readText with added null-terminator that enables sentinel-based search
- =?UTF-8?B?Tm9yZGzDtnc=?= (3/3) Aug 08 2017 Has anybody written a wrapper around `std.file.readText` (or
- Marco Leise (10/13) Aug 09 2017 What do you mean by similar? There are many ways to load a file
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.
Aug 08 2017
Am Tue, 08 Aug 2017 20:48:39 +0000 schrieb Nordl=C3=B6w <per.nordlow gmail.com>:Has anybody written a wrapper around `std.file.readText` (or=20 similar) that appends a final zero-byte terminator in order to=20 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 --=20 Marco
Aug 09 2017