Skip to content

Commit ea095e8

Browse files
committed
fix(renderer): don't use state.append/remove
That ends up deepcopy state.messages which creates a huge performance impact. No ones actually subscribed to messages so add/remove directly.
1 parent 87641f0 commit ea095e8

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lua/opencode/ui/renderer.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ function M.on_message_updated(message, revert_index)
372372

373373
if revert_index then
374374
if not found_msg then
375-
state.append('messages', msg)
375+
table.insert(state.messages, msg)
376376
end
377377
M._render_state:set_message(msg, 0, 0)
378378
return
@@ -390,7 +390,7 @@ function M.on_message_updated(message, revert_index)
390390
M._replace_message_in_buffer(msg.info.id, header_data)
391391
end
392392
else
393-
state.append('messages', msg)
393+
table.insert(state.messages, msg)
394394

395395
local header_data = formatter.format_message_header(msg)
396396
local range = M._write_formatted_data(header_data)
@@ -548,7 +548,7 @@ function M.on_message_removed(properties)
548548

549549
for i, msg in ipairs(state.messages or {}) do
550550
if msg.info.id == message_id then
551-
state.remove('messages', i)
551+
table.remove(state.messages, i)
552552
break
553553
end
554554
end

0 commit comments

Comments
 (0)