Skip to content

Commit 270b296

Browse files
committed
only use one clone
1 parent 55336c5 commit 270b296

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/main.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,18 @@ fn main_thread(
9696
sync_tx.send(true).expect("unable to send sync tx");
9797
data.raw_traffic.push(packet.clone());
9898

99-
if let Some(text) = console_text(show_timestamps, show_sent_cmds, &packet) {
100-
// append prints
101-
if let Ok(mut gui_data) = data_lock.write() {
102-
gui_data.prints.push(text);
103-
}
104-
}
99+
let text = console_text(show_timestamps, show_sent_cmds, &packet);
105100

106101
let split_data = split(&packet.payload);
107102
if data.dataset.is_empty() || failed_format_counter > 10 {
108103
// resetting dataset
109104
data.time = vec![];
110105
data.dataset = vec![vec![]; max(split_data.len(), 1)];
111106
if let Ok(mut gui_data) = data_lock.write() {
107+
// append prints
108+
if let Some(text) = text {
109+
gui_data.prints.push(text);
110+
}
112111
gui_data.plots = (0..max(split_data.len(), 1))
113112
.map(|i| (format!("Column {i}"), vec![]))
114113
.collect();
@@ -127,6 +126,10 @@ fn main_thread(
127126

128127
// appending data for GUI thread
129128
if let Ok(mut gui_data) = data_lock.write() {
129+
// append prints
130+
if let Some(text) = text {
131+
gui_data.prints.push(text);
132+
}
130133
// append plot-points
131134
for ((_label, graph), data_i) in
132135
gui_data.plots.iter_mut().zip(&data.dataset)
@@ -257,7 +260,7 @@ fn main_thread(
257260
}
258261
}
259262
}
260-
default(Duration::from_millis(10)) => {
263+
default(Duration::from_millis(1)) => {
261264
// occasionally push data to GUI
262265
}
263266
}

0 commit comments

Comments
 (0)