Why Strings as Classes?
Robert Fraser
fraserofthenight at gmail.com
Mon Aug 25 18:22:10 PDT 2008
BCS wrote:
> Reply to Benji,
>
>
>> The new JSON parser in the Tango library operates on templated string
>> arrays. If I want to read from a file or a socket, I have to first
>> slurp the whole thing into a character array, even though the
>> character-streaming would be more practical.
>>
>
> Unless you are only going to parse the start of the file or are going to
> be throwing away most of it *while you parse it, not after* The best way
> to parse a file is to load it all in one OS system call and then run a
> slicing parser (like the Tango XML parser) on that.
> One memory allocation and one load or a mmap, and then only the meta
> structures get allocated later.
There are cases where you might want to parse an XML file that won't fit
easily in main memory. I think a stream processing SAX parser would be a
good addition (perhaps not replacement for) the exiting one.
More information about the Digitalmars-d
mailing list