Open
Description
It would likely make sense to solve the de-duplication via a design change. We should switch towards using a HashMap
and a Vec
for the Timeline:
struct Timeline {
items: HashMap<EventId, TimelineItem>,
item_positions: Vec<EventId>,
}
Note that the exact types don't need to be Vec
and HashMap
but they should have properties that are equivalent to those two.
This would prevent us from ever inserting items that have the same EventId
into the timeline. Another nice advantage of this approach is that, if we have an operation that requires us to find the event by its ID, we can find the event in O(1) time instead of O(N) where N is the number of elements in the timeline.