From dd05c3b70de85a2942c371f7b837dbf53911edf6 Mon Sep 17 00:00:00 2001 From: Geert-Jan Zwiers Date: Thu, 5 Jan 2023 18:33:09 +0100 Subject: [PATCH] refactor(cli): clean up clones (#17268) --- cli/args/lockfile.rs | 2 +- cli/graph_util.rs | 2 +- cli/proc_state.rs | 6 +++--- cli/standalone.rs | 2 +- cli/tsc/mod.rs | 12 ++++++------ 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cli/args/lockfile.rs b/cli/args/lockfile.rs index 3c150a0894..5f690b3a13 100644 --- a/cli/args/lockfile.rs +++ b/cli/args/lockfile.rs @@ -112,7 +112,7 @@ impl Lockfile { None => match maybe_config_file { Some(config_file) => { if config_file.specifier.scheme() == "file" { - match config_file.clone().to_lock_config()? { + match config_file.to_lock_config()? { Some(LockConfig::Bool(lock)) if !lock => { return Ok(None); } diff --git a/cli/graph_util.rs b/cli/graph_util.rs index ba90245f88..62db0a82cd 100644 --- a/cli/graph_util.rs +++ b/cli/graph_util.rs @@ -597,7 +597,7 @@ pub fn error_for_any_npm_specifier( .specifiers() .filter_map(|(_, r)| match r { Ok((specifier, kind, _)) if kind == deno_graph::ModuleKind::External => { - Some(specifier.clone()) + Some(specifier) } _ => None, }) diff --git a/cli/proc_state.rs b/cli/proc_state.rs index 5ec8bc4e3e..2fe1f44f2e 100644 --- a/cli/proc_state.rs +++ b/cli/proc_state.rs @@ -239,7 +239,7 @@ impl ProcState { .resolve_local_node_modules_folder() .with_context(|| "Resolving local node_modules folder.")?, ); - if let Some(lockfile) = maybe_lockfile.clone() { + if let Some(lockfile) = maybe_lockfile { npm_resolver .add_lockfile_and_maybe_regenerate_snapshot(lockfile) .await?; @@ -328,8 +328,8 @@ impl ProcState { let mut cache = cache::FetchCacher::new( self.emit_cache.clone(), self.file_fetcher.clone(), - root_permissions.clone(), - dynamic_permissions.clone(), + root_permissions, + dynamic_permissions, ); let maybe_imports = self.options.to_maybe_imports()?; let maybe_resolver = diff --git a/cli/standalone.rs b/cli/standalone.rs index b37df5191d..006575b8d9 100644 --- a/cli/standalone.rs +++ b/cli/standalone.rs @@ -289,7 +289,7 @@ pub async fn run( user_agent: version::get_user_agent(), inspect: ps.options.is_inspecting(), }, - extensions: ops::cli_exts(ps.clone()), + extensions: ops::cli_exts(ps), extensions_with_js: vec![], startup_snapshot: Some(crate::js::deno_isolate_init()), unsafely_ignore_certificate_errors: metadata diff --git a/cli/tsc/mod.rs b/cli/tsc/mod.rs index 4784adfb9b..497105cb51 100644 --- a/cli/tsc/mod.rs +++ b/cli/tsc/mod.rs @@ -510,28 +510,28 @@ fn op_load(state: &mut OpState, args: Value) -> Result { let specifier = if let Some(remapped_specifier) = state.remapped_specifiers.get(&v.specifier) { - remapped_specifier.clone() + remapped_specifier } else if let Some(remapped_specifier) = state.root_map.get(&v.specifier) { - remapped_specifier.clone() + remapped_specifier } else { - specifier + &specifier }; let maybe_source = if let Some(ModuleEntry::Module { code, media_type: mt, .. }) = - graph_data.get(&graph_data.follow_redirect(&specifier)) + graph_data.get(&graph_data.follow_redirect(specifier)) { media_type = *mt; Some(Cow::Borrowed(code as &str)) } else if state .maybe_npm_resolver .as_ref() - .map(|resolver| resolver.in_npm_package(&specifier)) + .map(|resolver| resolver.in_npm_package(specifier)) .unwrap_or(false) { - media_type = MediaType::from(&specifier); + media_type = MediaType::from(specifier); let file_path = specifier.to_file_path().unwrap(); let code = std::fs::read_to_string(&file_path) .with_context(|| format!("Unable to load {}", file_path.display()))?;