Commit 92ae1e9
authored
fix: Optimize thought completion marking from O(n²) to O(n) (#1486)
## Problem
markThoughtCompletion scanned all subsequent items for every thought item using .slice().some(), making it O(n²) in conversation length.
## Changes
1. Replace nested scan with a single reverse pass using a Set to track seen turn contexts
2. Reduce time complexity from O(n²) to O(n) by eliminating repeated .slice().some() calls
3. Preserve identical completion semantics (checks for subsequent session_update or turnComplete)
## How did you test this?
Manually1 parent bc8fae9 commit 92ae1e9
1 file changed
Lines changed: 9 additions & 9 deletions
Lines changed: 9 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
101 | 103 | | |
102 | 104 | | |
103 | | - | |
104 | 105 | | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
112 | 110 | | |
113 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| |||
0 commit comments