diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2021-02-07 15:50:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-07 15:50:05 +0100 |
commit | a601d94aa1fa54074cd37ea011e874611f497938 (patch) | |
tree | 61842c10b52e019560bc40de60eb46c8a77f85e9 | |
parent | a6723fafc5cb4dfb58bfbc709845beaed8cd38e9 (diff) |
fix(runtime/tls): remove unnecessary clone calls (#9429)
-rw-r--r-- | runtime/ops/tls.rs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/runtime/ops/tls.rs b/runtime/ops/tls.rs index b81bd5e23..7a5636cd7 100644 --- a/runtime/ops/tls.rs +++ b/runtime/ops/tls.rs @@ -101,18 +101,17 @@ async fn op_start_tls( ) -> Result<Value, AnyError> { let args: StartTLSArgs = serde_json::from_value(args)?; let rid = args.rid as u32; - let cert_file = args.cert_file.clone(); - let mut domain = args.hostname; + let mut domain = args.hostname.as_str(); if domain.is_empty() { - domain.push_str("localhost"); + domain = "localhost"; } { super::check_unstable2(&state, "Deno.startTls"); let s = state.borrow(); let permissions = s.borrow::<Permissions>(); permissions.check_net(&(&domain, Some(0)))?; - if let Some(path) = cert_file.clone() { + if let Some(path) = &args.cert_file { permissions.check_read(Path::new(&path))?; } } @@ -134,7 +133,7 @@ async fn op_start_tls( config .root_store .add_server_trust_anchors(&webpki_roots::TLS_SERVER_ROOTS); - if let Some(path) = cert_file { + if let Some(path) = args.cert_file { let key_file = File::open(path)?; let reader = &mut BufReader::new(key_file); config.root_store.add_pem_file(reader).unwrap(); @@ -172,18 +171,17 @@ async fn op_connect_tls( _zero_copy: BufVec, ) -> Result<Value, AnyError> { let args: ConnectTLSArgs = serde_json::from_value(args)?; - let cert_file = args.cert_file.clone(); { let s = state.borrow(); let permissions = s.borrow::<Permissions>(); permissions.check_net(&(&args.hostname, Some(args.port)))?; - if let Some(path) = cert_file.clone() { + if let Some(path) = &args.cert_file { permissions.check_read(Path::new(&path))?; } } - let mut domain = args.hostname.clone(); + let mut domain = args.hostname.as_str(); if domain.is_empty() { - domain.push_str("localhost"); + domain = "localhost"; } let addr = resolve_addr(&args.hostname, args.port) @@ -198,7 +196,7 @@ async fn op_connect_tls( config .root_store .add_server_trust_anchors(&webpki_roots::TLS_SERVER_ROOTS); - if let Some(path) = cert_file { + if let Some(path) = args.cert_file { let key_file = File::open(path)?; let reader = &mut BufReader::new(key_file); config.root_store.add_pem_file(reader).unwrap(); |