Skip to content

Commit

Permalink
Optimize some clone() calls
Browse files Browse the repository at this point in the history
- remove two unnecessary clone() calls
- remove verbose log

Signed-off-by: Mikhail Malyshev <[email protected]>
  • Loading branch information
rucoder committed Nov 18, 2024
1 parent 3c1c098 commit 7314d10
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
17 changes: 7 additions & 10 deletions src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ impl Application {
self.model.borrow_mut().update_vault_status(status);
}

IpcMessage::LedBlinkCounter(led) => {
// self.raw_model.set_led_blink_counter(led);
IpcMessage::LedBlinkCounter(_led) => {
debug!("Got LedBlinkCounter");
}

Expand All @@ -189,8 +188,7 @@ impl Application {
let current_dpc = self.model.borrow().get_current_dpc().cloned();
if let Some(current_dpc) = current_dpc {
info!("send_dpc: Sending DPC for iface {}", &new.iface_name);
let dpc = current_dpc.clone();
let mut new_dpc = dpc.to_new_dpc_with_key("manual");
let mut new_dpc = current_dpc.to_new_dpc_with_key("manual");
// there are 3 cases:
// 1. iface is switched DHCP -> Static
// 2. iface is switched Static -> DHCP
Expand Down Expand Up @@ -603,20 +601,19 @@ impl Application {
match action.action {
UiActions::EditIfaceConfig(iface) => {
// get interface info by name
let model = self.model.borrow();
let iface_data = model
let iface_data = self
.model
.borrow()
.network
.iter()
.find(|e| e.name == iface)
.map(|e| e.clone());
.cloned();
if let Some(iface_data) = iface_data {
self.ui.show_ip_dialog(iface_data);
}
}
UiActions::ChangeServer => {
let is_onboarded = self.model.borrow().node_status.is_onboarded();

if is_onboarded {
if self.model.borrow().node_status.is_onboarded() {
self.ui.message_box(
"WARNING",
"The node is onboarded and the server URL cannot be changed.",
Expand Down
6 changes: 3 additions & 3 deletions src/model/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl From<EveNodeStatus> for NodeStatus {
impl MonitorModel {
fn get_network_settings(
&self,
network_status: DeviceNetworkStatus,
network_status: &DeviceNetworkStatus,
) -> Option<Vec<NetworkInterfaceStatus>> {
let ports = network_status.ports.as_ref()?;
Some(ports.iter().map(|p| p.into()).collect())
Expand Down Expand Up @@ -192,8 +192,8 @@ impl MonitorModel {
}

pub fn update_network_status(&mut self, net_status: DeviceNetworkStatus) {
self.dpc_key = Some(net_status.dpc_key.clone());
self.network = self.get_network_settings(net_status).unwrap_or_default();
self.network = self.get_network_settings(&net_status).unwrap_or_default();
self.dpc_key = Some(net_status.dpc_key);
}

pub fn update_vault_status(&mut self, vault_status: EveVaultStatus) {
Expand Down
2 changes: 0 additions & 2 deletions src/ui/summary_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ impl IPresenter for SummaryPage {
Layout::horizontal(vec![Constraint::Percentage(50), Constraint::Percentage(50)])
.areas(onboarding_status_and_app_sunnary_rect);

let ns = &model.borrow().node_status;
info!("Node statue {:?}", ns);
let server_url = ratatui::widgets::Paragraph::new(
model
.borrow()
Expand Down

0 comments on commit 7314d10

Please sign in to comment.