On the subject of an XML parser

Ali Çehreli acehreli at yahoo.com
Wed Aug 24 15:16:38 UTC 2022


On 8/22/22 15:51, Chris Piker wrote:

 > So depending on the use case, dxml works quite well.  For my own
 > purposes I'll need to find/create a ForwardRange adapter for stdin

The 'cached' range adaptor I mentioned on these forums a couple of times 
and in my DConf 2022 lightning talk converts any InputRange to a 
ForwardRange. (It does this by evaluating the elements once; so it would 
be valuable with generators as well; and in fact, a generator use case 
was why I wrote it.)

(Aside: It actually makes a RandomAccessRange because it supports 
opIndex as well but it does not honor O(1): It will grab 'n' elements if 
you say myRange[n] and if those elements are not in the cache yet.)

Currently it has an assumed performance issue because it uses a regular 
D slice, and the way it uses the slice incurs an allocation cost per 
element. There are different ways of dealing with that issue but I 
haven't finished that yet.

Ali



More information about the Digitalmars-d mailing list