diff options
Diffstat (limited to 'cli/file_fetcher.rs')
-rw-r--r-- | cli/file_fetcher.rs | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/cli/file_fetcher.rs b/cli/file_fetcher.rs index 933cbf203..50544bfd9 100644 --- a/cli/file_fetcher.rs +++ b/cli/file_fetcher.rs @@ -55,11 +55,7 @@ struct FileCache(Arc<Mutex<HashMap<ModuleSpecifier, File>>>); impl FileCache { pub fn get(&self, specifier: &ModuleSpecifier) -> Option<File> { let cache = self.0.lock().unwrap(); - if let Some(file) = cache.get(specifier) { - Some(file.clone()) - } else { - None - } + cache.get(specifier).cloned() } pub fn insert(&self, specifier: ModuleSpecifier, file: File) -> Option<File> { @@ -259,18 +255,16 @@ fn map_js_like_extension( } /// Remove shebangs from the start of source code strings -fn strip_shebang(value: String) -> String { +fn strip_shebang(mut value: String) -> String { if value.starts_with("#!") { - let value = if let Some(mid) = value.find('\n') { + if let Some(mid) = value.find('\n') { let (_, rest) = value.split_at(mid); - rest.to_string() + value = rest.to_string() } else { - "".to_string() - }; - value - } else { - value + value.clear() + } } + value } /// A structure for resolving, fetching and caching source files. |