On the subject of an XML parser

tsbockman thomas.bockman at gmail.com
Mon Oct 3 16:12:34 UTC 2022


On Monday, 3 October 2022 at 14:46:13 UTC, Ali Çehreli wrote:
> CircularBlocks does not move elements. It just allocates and 
> adds a new block to its "array of slices" queue.

Repeatedly appending `~=` to a dynamic array, as `CircularBlocks` 
does 
[here](https://github.com/acehreli/alid/blob/main/circularblocks/alid/circularblocks.d#L422), will reallocate and move the elements over to the new memory whenever the new `.length` would exceed `.capacity`:
```D
     void addExistingBlock_(ubyte[] buffer)
     {
         import std.array : back;

         blocks ~= ReusableBlock!T(buffer);
         capacity_ += blocks.back.capacity;
     }
```


More information about the Digitalmars-d mailing list