优化 event.rs 中的克隆操作,减少 monitor 的克隆次数从 3 次减少到 1 次
This commit is contained in:
parent
562a2d566b
commit
4bb9bdd27d
|
|
@ -159,14 +159,14 @@ impl EventManager {
|
|||
value_changed,
|
||||
};
|
||||
|
||||
if let Err(e) = connection_manager.update_point_monitor_data(monitor.clone()).await {
|
||||
// 只克隆一次 monitor,减少内存分配
|
||||
let monitor_clone = monitor.clone();
|
||||
if let Err(e) = connection_manager.update_point_monitor_data(monitor_clone).await {
|
||||
tracing::error!("Failed to update point monitor data for point {}: {}", point_id, e);
|
||||
}
|
||||
|
||||
if let Some(ws_manager) = &ws_manager_clone {
|
||||
let ws_message = crate::websocket::WsMessage::PointNewValue(
|
||||
monitor.clone(),
|
||||
);
|
||||
let ws_message = crate::websocket::WsMessage::PointNewValue(monitor);
|
||||
|
||||
if let Err(e) = ws_manager.send_to_public(ws_message.clone()).await {
|
||||
tracing::error!("Failed to send WebSocket message to public room: {}", e);
|
||||
|
|
|
|||
Loading…
Reference in New Issue