On the subject of an XML parser

Ali Çehreli acehreli at yahoo.com
Mon Sep 12 09:29:11 UTC 2022


On 8/24/22 08:16, Ali Çehreli wrote:
 > 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.)

It is now available:

   https://code.dlang.org/packages/alid

 > (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.)

I realized that it is still O(1) because the seemingly unnecessarily 
grabbed elements would still count as "amortized" because they are 
readily available at O(1) for consumption of both this range and all its 
.save'd ranges.

 > 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.

I solved that by writing the `alid.circularblocks` module.

Ali



More information about the Digitalmars-d mailing list