Skip to content

Commit

Permalink
message_list_view: Clarify imprecise performance comment.
Browse files Browse the repository at this point in the history
A single call to this function doesn't have a material performance
impact when tested with 20k messages while scrolling in combined feed
view; likely because only 400 messages can be in the structure at any
give time given render windows.

But calling this in a loop somewhere would be a bad idea.
  • Loading branch information
amanagr authored and timabbott committed Apr 22, 2024
1 parent 2d824e8 commit 9702ff3
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions web/src/message_list_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -1265,12 +1265,11 @@ export class MessageListView {
}

_find_message_group(message_group_id) {
// Ideally, we'd maintain this data structure with a hash
// table or at least a pointer from the message containers (in
// either case, updating the data structure when message
// groups are merged etc.), but we only call this from flows
// like message editing, so it's not a big performance
// problem.
// Finds the message group with a given message group ID.
//
// This function does a linear search, so be careful to avoid
// calling it in a loop. If you need that, we'll need to add a
// hash table to make this O(1) runtime.
return this._message_groups.find(
// Since we don't have a way to get a message group from
// the containing message container, we just do a search
Expand Down

0 comments on commit 9702ff3

Please sign in to comment.