[PATCH] D38433: Introduce a specialized data structure to be used in a subsequent change

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 10 10:37:41 PDT 2017


On Tue, Oct 10, 2017 at 10:31 AM, Chandler Carruth via Phabricator via
llvm-commits <llvm-commits at lists.llvm.org> wrote:

> chandlerc added a comment.
>
> Have you considered building a `ChunkedVector` instead of a `ChunkedList`?
> Specifically, there is a great trick where you use a single index with the
> low bits being an index into the chunk and the high bits being an index
> into a vector of pointers. It has many of the benefits you list and is a
> bit simpler I think. It also supports essentially the entire vector API if
> desired. Both bi-directional and even random access are reasonably
> efficient. Good locality, etc.
>
> The only downside I can see is that is is possible to implement insertion
> into the middle of `ChunkedList` with bounded complexity, but with
> `ChunkedVector` it would still be linear. However, you don't seem to have
> implemented arbitrary insertion and so I'm hoping that isn't necessary.
>

If you really need it, you can play gap-buffer like games so that you can
make it relatively sane for most patterns.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171010/e41960ec/attachment.html>


More information about the llvm-commits mailing list