Skip to content

Commit 26d3a39

Browse files
committed
refactor(linter): remove ModuleContentOwner abstraction (#12331)
Pure refactor. Remove `ModuleContentOwner` abstraction. It's just a wrapper around `AllocatorGuard` and adds no value in itself, so remove it and use `AllocatorGuard` directly.
1 parent b144048 commit 26d3a39

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

crates/oxc_linter/src/service/runtime.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct ResolvedModuleRecord {
8888

8989
self_cell! {
9090
struct ModuleContent<'alloc_pool> {
91-
owner: ModuleContentOwner<'alloc_pool>,
91+
owner: AllocatorGuard<'alloc_pool>,
9292
#[not_covariant]
9393
dependent: ModuleContentDependent,
9494
}
@@ -101,10 +101,6 @@ struct ModuleContentDependent<'a> {
101101
// Safety: dependent borrows from owner. They're safe to be sent together.
102102
unsafe impl Send for ModuleContent<'_> {}
103103

104-
struct ModuleContentOwner<'alloc_pool> {
105-
allocator: AllocatorGuard<'alloc_pool>,
106-
}
107-
108104
/// source text and semantic for each source section. They are in the same order as `ProcessedModule.section_module_records`
109105
type SectionContents<'a> = SmallVec<[SectionContent<'a>; 1]>;
110106
struct SectionContent<'a> {
@@ -812,9 +808,8 @@ impl Runtime {
812808
if self.paths.contains(path) {
813809
let allocator = self.allocator_pool.get();
814810

815-
let build = ModuleContent::try_new(ModuleContentOwner { allocator }, |owner| {
816-
let Some(stt) =
817-
self.get_source_type_and_text(Path::new(path), ext, &owner.allocator)
811+
let build = ModuleContent::try_new(allocator, |allocator| {
812+
let Some(stt) = self.get_source_type_and_text(Path::new(path), ext, allocator)
818813
else {
819814
return Err(());
820815
};
@@ -834,7 +829,7 @@ impl Runtime {
834829
check_syntax_errors,
835830
source_type,
836831
source_text,
837-
&owner.allocator,
832+
allocator,
838833
Some(&mut section_contents),
839834
);
840835

0 commit comments

Comments
 (0)