From ab47a8e6c20398514f3680775149c8f005ea3ab0 Mon Sep 17 00:00:00 2001 From: Bryan Van de Ven Date: Mon, 9 Oct 2023 14:23:03 -0700 Subject: [PATCH 1/2] Use common log prefix for window title --- src/app.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index c24d166..bada405 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,5 +1,6 @@ use std::collections::{BTreeMap, BTreeSet, VecDeque}; use std::fmt; +use std::path::Path; use std::time::Duration; #[cfg(not(target_arch = "wasm32"))] use std::time::Instant; @@ -2443,8 +2444,28 @@ pub fn start(data_sources: Vec>) { env_logger::try_init().unwrap_or(()); // Log to stderr (if you run with `RUST_LOG=debug`). let native_options = eframe::NativeOptions::default(); + + let mut paths = BTreeSet::new(); + let arguments: Vec = std::env::args().collect(); + for argument in &arguments[1..] { + if !argument.starts_with("--") { + let path = Path::new(&argument) + .parent() + .unwrap() + .to_str() + .unwrap() + .to_string(); + paths.insert(path); + } + } + let app_name = if paths.len() == 1 { + paths.pop_last().unwrap() + } else { + String::from("Legion Prof") + }; + eframe::run_native( - "Legion Prof", + &app_name, native_options, Box::new(|cc| Box::new(ProfApp::new(cc, data_sources))), ) From 323c1707c7fe65d75034b0fca215aeac65169b5f Mon Sep 17 00:00:00 2001 From: Bryan Van de Ven Date: Mon, 9 Oct 2023 14:25:47 -0700 Subject: [PATCH 2/2] clippy fixes --- src/app.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/app.rs b/src/app.rs index bada405..ad66d3d 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1193,7 +1193,7 @@ impl SearchState { if !self.result_cache.contains_key(entry.entry_id()) { self.result_cache .entry(entry.entry_id().clone()) - .or_insert_with(BTreeMap::new); + .or_default(); } // Always recurse into tiles, because results can be fetched @@ -1215,7 +1215,7 @@ impl SearchState { .and_modify(|_| { result = false; }) - .or_insert_with(BTreeMap::new); + .or_default(); result } @@ -1251,13 +1251,8 @@ impl SearchState { let level1_index = entry_id.slot_index(1).unwrap(); let level2_index = entry_id.slot_index(2).unwrap(); - let level0_subtree = self - .entry_tree - .entry(level0_index) - .or_insert_with(BTreeMap::new); - let level1_subtree = level0_subtree - .entry(level1_index) - .or_insert_with(BTreeSet::new); + let level0_subtree = self.entry_tree.entry(level0_index).or_default(); + let level1_subtree = level0_subtree.entry(level1_index).or_default(); level1_subtree.insert(level2_index); } }