@@ -100,16 +100,10 @@ impl Alloc for Bump {
100100 // This will go away when we add a custom allocator to oxc.
101101 #[ cfg( all( feature = "track_allocations" , not( feature = "disable_track_allocations" ) ) ) ]
102102 unsafe {
103- use crate :: Allocator ;
104- use std:: {
105- mem:: offset_of,
106- ptr,
107- sync:: atomic:: { AtomicUsize , Ordering } ,
108- } ;
109- #[ expect( clippy:: cast_possible_wrap) ]
110- const OFFSET : isize = ( offset_of ! ( Allocator , num_alloc) as isize )
111- - ( offset_of ! ( Allocator , bump) as isize ) ;
112- let num_alloc_ptr = ptr:: from_ref ( self ) . byte_offset ( OFFSET ) . cast :: < AtomicUsize > ( ) ;
103+ use crate :: allocator:: NUM_ALLOC_FIELD_OFFSET ;
104+ use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
105+ let num_alloc_ptr =
106+ std:: ptr:: from_ref ( self ) . byte_offset ( NUM_ALLOC_FIELD_OFFSET ) . cast :: < AtomicUsize > ( ) ;
113107 let num_alloc = num_alloc_ptr. as_ref ( ) . unwrap_unchecked ( ) ;
114108 num_alloc. fetch_add ( 1 , Ordering :: SeqCst ) ;
115109 }
@@ -157,16 +151,11 @@ impl Alloc for Bump {
157151 // This will go away when we add a custom allocator to oxc.
158152 #[ cfg( all( feature = "track_allocations" , not( feature = "disable_track_allocations" ) ) ) ]
159153 unsafe {
160- use crate :: Allocator ;
161- use std:: {
162- mem:: offset_of,
163- ptr,
164- sync:: atomic:: { AtomicUsize , Ordering } ,
165- } ;
166- #[ expect( clippy:: cast_possible_wrap) ]
167- const OFFSET : isize = ( offset_of ! ( Allocator , num_realloc) as isize )
168- - ( offset_of ! ( Allocator , bump) as isize ) ;
169- let num_realloc_ptr = ptr:: from_ref ( self ) . byte_offset ( OFFSET ) . cast :: < AtomicUsize > ( ) ;
154+ use crate :: allocator:: NUM_REALLOC_FIELD_OFFSET ;
155+ use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
156+ let num_realloc_ptr = std:: ptr:: from_ref ( self )
157+ . byte_offset ( NUM_REALLOC_FIELD_OFFSET )
158+ . cast :: < AtomicUsize > ( ) ;
170159 let num_realloc = num_realloc_ptr. as_ref ( ) . unwrap_unchecked ( ) ;
171160 num_realloc. fetch_add ( 1 , Ordering :: SeqCst ) ;
172161 }
0 commit comments