mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-10 03:27:57 +00:00
Fix O(n²) performance in get_message_list by replacing insert(0) with append+reverse (#21588)
Co-authored-by: Jordan <CenteredAxis@users.noreply.github.com>
This commit is contained in:
parent
c5c31ab769
commit
326599b8db
1 changed files with 2 additions and 3 deletions
|
|
@ -93,12 +93,11 @@ def get_message_list(messages_map, message_id):
|
|||
message_list = []
|
||||
|
||||
while current_message:
|
||||
message_list.insert(
|
||||
0, current_message
|
||||
) # Insert the message at the beginning of the list
|
||||
message_list.append(current_message)
|
||||
parent_id = current_message.get("parentId") # Use .get() for safety
|
||||
current_message = messages_map.get(parent_id) if parent_id else None
|
||||
|
||||
message_list.reverse()
|
||||
return message_list
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue