mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 05:47:50 -05:00
[PR #22194] [MERGED] perf: rewrite createMessagesList from recursive to iterative #81417
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/22194
Author: @Classic298
Created: 3/3/2026
Status: ✅ Merged
Merged: 3/6/2026
Merged by: @tjbck
Base:
dev← Head:perf/iterative-create-messages-list📝 Commits (1)
653b3b6perf: rewrite createMessagesList from recursive to iterative📊 Changes
1 file changed (+11 additions, -11 deletions)
View changed files
📝
src/lib/utils/index.ts(+11 -11)📄 Description
Replace the recursive spread-based implementation with an iterative push+reverse approach. The recursive version created a new array at each level of recursion via spread, resulting in O(d^2) array copies where d is the conversation depth. The iterative version walks from the target message to the root, pushes each message, and reverses once at the end for O(d) total work.
No behavioral change - same input produces the same output array.
This was tested extensively
No side effects observed even in branched chats and navigating between branches.
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.