From c37598106546b829c0af6f9a23c5d1a47e445112 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Mon, 21 Jul 2025 13:26:06 +0000 Subject: [PATCH] refactor(napi/oxlint): simplify atomic operations (#12425) `AtomicBool::store` does the same as `fetch_and(false)` / `fetch_or(true)`, is simpler, and possibly a little bit cheaper. Not sure why I didn't use it in the first place in #12381! --- crates/oxc_allocator/src/pool_fixed_size.rs | 2 +- napi/oxlint2/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/oxc_allocator/src/pool_fixed_size.rs b/crates/oxc_allocator/src/pool_fixed_size.rs index 09c4b141b1043..eb9e4bcddad43 100644 --- a/crates/oxc_allocator/src/pool_fixed_size.rs +++ b/crates/oxc_allocator/src/pool_fixed_size.rs @@ -324,7 +324,7 @@ pub unsafe fn free_fixed_size_allocator(metadata_ptr: NonNull ExternalLinterCb { // stored at the pointer returned by `Allocator::fixed_size_metadata_ptr`. let metadata = unsafe { metadata_ptr.as_ref() }; // TODO: Is `Ordering::SeqCst` excessive here? - let already_sent_to_js = metadata.is_double_owned.fetch_or(true, Ordering::SeqCst); + let already_sent_to_js = metadata.is_double_owned.swap(true, Ordering::SeqCst); (metadata.id, already_sent_to_js) };