diff options
author | Geert-Jan Zwiers <geertjanzwiers@protonmail.com> | 2023-01-26 23:24:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-26 23:24:03 +0100 |
commit | 7f38f30a5c0eb06c5b85d1c7ac26a480c210aab6 (patch) | |
tree | 805c717b5aaf7124a09a3f19f6d2c2d459d2d959 /cli/file_fetcher.rs | |
parent | 21065797f6dce285e55705007f54abe2bafb611c (diff) |
refactor(lsp): fewer clones (#17551)
Diffstat (limited to 'cli/file_fetcher.rs')
-rw-r--r-- | cli/file_fetcher.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/cli/file_fetcher.rs b/cli/file_fetcher.rs index 21140c66d..4e417778e 100644 --- a/cli/file_fetcher.rs +++ b/cli/file_fetcher.rs @@ -154,7 +154,7 @@ fn get_validated_scheme( /// the value of a content type header. pub fn map_content_type( specifier: &ModuleSpecifier, - maybe_content_type: Option<String>, + maybe_content_type: Option<&String>, ) -> (MediaType, Option<String>) { if let Some(content_type) = maybe_content_type { let mut content_types = content_type.split(';'); @@ -226,7 +226,7 @@ impl FileFetcher { .ok_or_else(|| { generic_error("Cannot convert specifier to cached filename.") })?; - let maybe_content_type = headers.get("content-type").cloned(); + let maybe_content_type = headers.get("content-type"); let (media_type, maybe_charset) = map_content_type(specifier, maybe_content_type); let source = get_source_from_bytes(bytes, maybe_charset)?; @@ -308,8 +308,7 @@ impl FileFetcher { } let (source, content_type) = get_source_from_data_url(specifier)?; - let (media_type, _) = - map_content_type(specifier, Some(content_type.clone())); + let (media_type, _) = map_content_type(specifier, Some(&content_type)); let local = self @@ -372,7 +371,7 @@ impl FileFetcher { let bytes = blob.read_all().await?; let (media_type, maybe_charset) = - map_content_type(specifier, Some(content_type.clone())); + map_content_type(specifier, Some(&content_type)); let source = get_source_from_bytes(bytes, maybe_charset)?; let local = @@ -1028,7 +1027,7 @@ mod tests { for (specifier, maybe_content_type, media_type, maybe_charset) in fixtures { let specifier = resolve_url_or_path(specifier).unwrap(); assert_eq!( - map_content_type(&specifier, maybe_content_type), + map_content_type(&specifier, maybe_content_type.as_ref()), (media_type, maybe_charset) ); } |