Skip to content

Commit b154785

Browse files
committed
refactor(file): Pull out extension lookup
1 parent 7fc4443 commit b154785

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/file/source/file.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,9 @@ impl FileSourceFile {
3838
if let Some(format) = format_hint {
3939
return Ok((filename, Box::new(format)));
4040
} else {
41+
let ext = filename.extension().unwrap_or_default().to_string_lossy();
4142
for (format, extensions) in all_extensions().iter() {
42-
if extensions.contains(
43-
&filename
44-
.extension()
45-
.unwrap_or_default()
46-
.to_string_lossy()
47-
.as_ref(),
48-
) {
43+
if extensions.contains(&ext.as_ref()) {
4944
return Ok((filename, Box::new(*format)));
5045
}
5146
}

0 commit comments

Comments
 (0)