summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrmsyn <117854522+rmsyn@users.noreply.github.com>2023-11-29 05:34:36 +0000
committerGitHub <noreply@github.com>2023-11-29 14:34:36 +0900
commit4a351e22bed2d9de4fc0d677872eb5a8c338c439 (patch)
treeff4de7b6e08b559de6dd968dc6f18d333d722c0c
parent9a38ad2e152b914c75f0156e5a9985fe22013346 (diff)
fixup: zellij-server: fix compiler warnings (#2873)
* fixup: zellij-server: fix compiler warnings Fixes compiler warnings about variables not being read before being reassigned a value, and an unused variable. Removes unnecessary intermediate local variables. * style(fmt): rustfmt --------- Co-authored-by: Jae-Heon Ji <atx6419@gmail.com>
-rw-r--r--zellij-server/src/os_input_output.rs46
1 files changed, 22 insertions, 24 deletions
diff --git a/zellij-server/src/os_input_output.rs b/zellij-server/src/os_input_output.rs
index 8a2a4cdc7..25e2cafe2 100644
--- a/zellij-server/src/os_input_output.rs
+++ b/zellij-server/src/os_input_output.rs
@@ -580,18 +580,17 @@ impl ServerOsApi for ServerOsInputOutput {
.lock()
.to_anyhow()
.with_context(err_context)?;
- let mut terminal_id = None;
- {
- let current_ids: BTreeSet<u32> = self
- .terminal_id_to_raw_fd
- .lock()
- .to_anyhow()
- .with_context(err_context)?
- .keys()
- .copied()
- .collect();
- terminal_id = current_ids.last().map(|l| l + 1).or(Some(0));
- }
+ let terminal_id = self
+ .terminal_id_to_raw_fd
+ .lock()
+ .to_anyhow()
+ .with_context(err_context)?
+ .keys()
+ .copied()
+ .collect::<BTreeSet<u32>>()
+ .last()
+ .map(|l| l + 1)
+ .or(Some(0));
match terminal_id {
Some(terminal_id) => {
self.terminal_id_to_raw_fd
@@ -622,18 +621,17 @@ impl ServerOsApi for ServerOsInputOutput {
fn reserve_terminal_id(&self) -> Result<u32> {
let err_context = || "failed to reserve a terminal ID".to_string();
- let mut terminal_id = None;
- {
- let current_ids: BTreeSet<u32> = self
- .terminal_id_to_raw_fd
- .lock()
- .to_anyhow()
- .with_context(err_context)?
- .keys()
- .copied()
- .collect();
- terminal_id = current_ids.last().map(|l| l + 1).or(Some(0));
- }
+ let terminal_id = self
+ .terminal_id_to_raw_fd
+ .lock()
+ .to_anyhow()
+ .with_context(err_context)?
+ .keys()
+ .copied()
+ .collect::<BTreeSet<u32>>()
+ .last()
+ .map(|l| l + 1)
+ .or(Some(0));
match terminal_id {
Some(terminal_id) => {
self.terminal_id_to_raw_fd