Skip to content

Commit 5693ef3

Browse files
committed
refactor(linter): avoid unnecessary var initialization
1 parent a0c16b9 commit 5693ef3

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

crates/oxc_linter/src/service/runtime.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -887,13 +887,13 @@ impl Runtime {
887887
return None;
888888
}
889889

890-
let mut records = SmallVec::<[Result<ResolvedModuleRecord, Vec<OxcDiagnostic>>; 1]>::new();
891-
let mut module_content: Option<ModuleContent> = None;
890+
let allocator_guard = self.allocator_pool.get();
892891

893892
if self.paths.contains(path) {
894-
let allocator_guard = self.allocator_pool.get();
893+
let mut records =
894+
SmallVec::<[Result<ResolvedModuleRecord, Vec<OxcDiagnostic>>; 1]>::new();
895895

896-
let mc = ModuleContent::try_new(allocator_guard, |allocator| {
896+
let module_content = ModuleContent::try_new(allocator_guard, |allocator| {
897897
let Some(stt) = self.get_source_type_and_text(Path::new(path), ext, allocator)
898898
else {
899899
return Err(());
@@ -920,11 +920,10 @@ impl Runtime {
920920

921921
Ok(ModuleContentDependent { source_text, section_contents })
922922
});
923-
let mc = mc.ok()?;
923+
let module_content = module_content.ok()?;
924924

925-
module_content = Some(mc);
925+
Some(ProcessedModule { section_module_records: records, content: Some(module_content) })
926926
} else {
927-
let allocator_guard = self.allocator_pool.get();
928927
let allocator = &*allocator_guard;
929928

930929
let stt = self.get_source_type_and_text(Path::new(path), ext, allocator)?;
@@ -937,7 +936,7 @@ impl Runtime {
937936
}
938937
};
939938

940-
records = self.process_source(
939+
let records = self.process_source(
941940
Path::new(path),
942941
ext,
943942
check_syntax_errors,
@@ -946,9 +945,9 @@ impl Runtime {
946945
allocator,
947946
None,
948947
);
949-
}
950948

951-
Some(ProcessedModule { section_module_records: records, content: module_content })
949+
Some(ProcessedModule { section_module_records: records, content: None })
950+
}
952951
}
953952

954953
#[expect(clippy::too_many_arguments)]

0 commit comments

Comments
 (0)