From ac0a82af71c992f767a71ab0768c3240e060dd20 Mon Sep 17 00:00:00 2001 From: Boshen <1430279+Boshen@users.noreply.github.com> Date: Mon, 7 Oct 2024 14:43:23 +0000 Subject: [PATCH] perf(linter): reuse allocator when there are multiple source texts (#6337) --- crates/oxc_linter/src/service.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/oxc_linter/src/service.rs b/crates/oxc_linter/src/service.rs index 05479b86a..4564dd909 100644 --- a/crates/oxc_linter/src/service.rs +++ b/crates/oxc_linter/src/service.rs @@ -271,8 +271,11 @@ impl Runtime { // source code after each fix. let mut fix_offset: i32 = 0; - for source in sources { - let allocator = Allocator::default(); + let mut allocator = Allocator::default(); + for (i, source) in sources.into_iter().enumerate() { + if i >= 1 { + allocator.reset(); + } let mut messages = self.process_source( path, &allocator,