Restructure `RoomsList` to store the list of `all_rooms` as a HashMap keyed by room ID
The full set/list of all rooms should not be ordered by default, which is what's currently happening implicitly because RoomsList::all_rooms is a Vec.
This is also especially relevant since we have some pending PRs about ordering/sorting/filtering the rooms list, so basically we're already encountering the need to separate the concern of storing the list from the concern of displaying the ordered/filtered list.
That would remove the need for the newly-added additional field RoomScreen::rooms_list_owned_room_id_map too.
Originally posted by @kevinaboos in https://github.com/project-robius/robrix/pull/181#discussion_r1796231692
I am looking at this : )
Our intention is to change Vec<RoomPreviewEntry> to HashMap<OwnedRoomID, RoomPreviewEntry>, right?
Btw, I think if we want to use HashMap instead of normal tuple, we should avoid the standard library HashMap, its performance is very poor (not as good as Java), let me see what high-performance HashMap is available on crates.io : )
I am a little pulzz about this, does the OwnedRoomID under RoomPerviewEntry need to be removed?
This has already been self-assigned to me, but sure, you can take a look at it.
Our intention is to change
Vec<RoomPreviewEntry>toHashMap<OwnedRoomID, RoomPreviewEntry>, right?
yep. I wouldn't be concerned about performance, even the largest matrix accounts have like ~2000 rooms. Also, don't get swept up in premature optimization. There are other hashmaps, e.g., hashbrown, but std is fine for now.
(its performance is very poor (not as good as Java)
I sincerely doubt that, but it's not important right now.
I am a little pulzz about this, does the
OwnedRoomIDunderRoomPerviewEntryneed to be removed?
nope, why? we'd still want easy access to a room's ID from its RoomPreviewEntry. Again, this issue is specifically about changing the choice of data structure to store the list of rooms, so let's restrict the scope to that.
I see. Thanks very much: )
Then, There is no Vec, and the index is not avilibale in HashMap.
So, Should we change rooms_list_map from HashMap<u64, usize> to HashMap<OwnedRoomID, u64> ? (u64 is Widget ID) :)
One last question, why my pr cannot checks automatically?, thanks :)
what PR are you referring to? Also we don't have any checks, I removed the old one but will add some basic ones later.