[Webkit-unassigned] [Bug 224726] Make container naming a bit more consistent

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Apr 18 10:24:43 PDT 2021


https://bugs.webkit.org/show_bug.cgi?id=224726

--- Comment #2 from Sam Weinig <sam at webkit.org> ---
(In reply to Darin Adler from comment #1)
> You didn’t mention Deque. Are there any other that are similar/adjacent?
> ListHashSet? Linked lists?

In addition to Deque, there is BitVector and FastBitVector, and I initially felt they were different enough, but that seems silly.

I was also limiting this to just containers that support random access, but again, that now seems silly. 

Non-random access containers we have are:

- SinglyLinkedList
- SinglyLinkedListWithTail
- DoublyLinkedList
- SentinelLinkedList
- ListHashSet


Fortunately here, we have a pretty consistent naming. All non-random access based list containers use the word "List", which I think is appropriate.

For the random access ones (with the exception of Deque, which I think we could see as more as an adaptor for any random access container, though that is not currently how it is implemented), it seems like the most prevelent words we have are "Vector" and "Buffer", with RefCountedArray being the only container not using one of those terms. Given that std::array implies a compile time size, I think RefCountedArray is ultimately more misleading than necessary, and we should probably converge its naming with FixedVector, which is almost identical to it, but doesn't have the refcount based aliasing. 

Speaking of FixedVector, that name kind of feels like an oxymoron to me, as Vector makes me think of something that is not fixed. I kind of like the word "Buffer" as a container that is a capacity + element array (with no separate "used size" being tracked), and we use that for containers like VectorBuffer (arguably not true since it has the m_size for packing), StringBuffer and ConcurrentBuffer (to an extent).

My initial thoughts on names would be:

"Vector" :: A container that conceptually tracks a separate capacity and size.
"Buffer" :: A container that conceptually tracks just capacity.

I think most of the containers follow these rules with the exception of FixedVector and RefCountedArray.

The primary goal both of these is be only a word when empty, so I think following the lead of WordLock, and prefixing them with "Word" would be useful. My proposal would be:

RefCountedArray -> WordRefCountedBuffer
FixedVector -> WordBuffer

Though, now that read the latter, it kind of seems like it is a buffer of words. We have also use the term "Compact" in other containers to emphasize they optimize for space with CompactPointerTuple, CompactRefPtrTuple and CompactUniquePtrTuple, so perhaps:

RefCountedArray -> CompactRefCountedBuffer
FixedVector -> CompactBuffer

?

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20210418/23d004bc/attachment.htm>


More information about the webkit-unassigned mailing list