From 9702ff3539aa3fd8f2a237e75c4a8cc6abda03a7 Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Mon, 22 Apr 2024 04:56:16 +0000 Subject: [PATCH] message_list_view: Clarify imprecise performance comment. 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. --- web/src/message_list_view.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/web/src/message_list_view.js b/web/src/message_list_view.js index b2b5703c75..0f026534bb 100644 --- a/web/src/message_list_view.js +++ b/web/src/message_list_view.js @@ -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