Reduce allocations (#31223)

Release Notes:

- N/A
This commit is contained in:
tidely 2025-05-23 14:25:17 +03:00 committed by GitHub
parent f435304209
commit fbc922ad46
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 14 additions and 20 deletions

View file

@ -158,8 +158,8 @@ fn add_recent_folders(
.iter() .iter()
.map(|p| { .map(|p| {
p.file_name() p.file_name()
.map(|name| name.to_string_lossy().to_string()) .map(|name| name.to_string_lossy())
.unwrap_or_else(|| p.to_string_lossy().to_string()) .unwrap_or_else(|| p.to_string_lossy())
}) })
.join(", "); .join(", ");

View file

@ -241,7 +241,7 @@ fn get_monitor_info(hmonitor: HMONITOR) -> anyhow::Result<MONITORINFOEXW> {
fn generate_uuid(device_name: &[u16]) -> Uuid { fn generate_uuid(device_name: &[u16]) -> Uuid {
let name = device_name let name = device_name
.iter() .iter()
.flat_map(|&a| a.to_be_bytes().to_vec()) .flat_map(|&a| a.to_be_bytes())
.collect_vec(); .collect_vec();
Uuid::new_v5(&Uuid::NAMESPACE_DNS, &name) Uuid::new_v5(&Uuid::NAMESPACE_DNS, &name)
} }

View file

@ -164,13 +164,9 @@ impl DapLocator for CargoLocator {
Ok(DebugRequest::Launch(task::LaunchRequest { Ok(DebugRequest::Launch(task::LaunchRequest {
program: executable, program: executable,
cwd: build_config.cwd.clone(), cwd: build_config.cwd,
args, args,
env: build_config env: build_config.env.into_iter().collect(),
.env
.iter()
.map(|(k, v)| (k.clone(), v.clone()))
.collect(),
})) }))
} }
} }

View file

@ -521,10 +521,8 @@ pub fn deserialize_path_matches(glob_set: &str) -> anyhow::Result<PathMatcher> {
let globs = glob_set let globs = glob_set
.split(',') .split(',')
.map(str::trim) .map(str::trim)
.filter(|&glob_str| (!glob_str.is_empty())) .filter(|&glob_str| !glob_str.is_empty());
.map(|glob_str| glob_str.to_owned()) Ok(PathMatcher::new(globs)?)
.collect::<Vec<_>>();
Ok(PathMatcher::new(&globs)?)
} }
#[cfg(test)] #[cfg(test)]

View file

@ -306,9 +306,9 @@ impl Inventory {
.unwrap_or((None, None, None)); .unwrap_or((None, None, None));
self.list_tasks(file, language, worktree_id.or(buffer_worktree_id), cx) self.list_tasks(file, language, worktree_id.or(buffer_worktree_id), cx)
.iter() .into_iter()
.find(|(_, template)| template.label == label) .find(|(_, template)| template.label == label)
.map(|val| val.1.clone()) .map(|val| val.1)
} }
/// Pulls its task sources relevant to the worktree and the language given, /// Pulls its task sources relevant to the worktree and the language given,

View file

@ -108,14 +108,14 @@ impl Project {
}); });
} }
} }
let settings = TerminalSettings::get(settings_location, cx).clone(); let venv = TerminalSettings::get(settings_location, cx)
.detect_venv
.clone();
cx.spawn(async move |project, cx| { cx.spawn(async move |project, cx| {
let python_venv_directory = if let Some(path) = path.clone() { let python_venv_directory = if let Some(path) = path {
project project
.update(cx, |this, cx| { .update(cx, |this, cx| this.python_venv_directory(path, venv, cx))?
this.python_venv_directory(path, settings.detect_venv.clone(), cx)
})?
.await .await
} else { } else {
None None