refactor(allocator): replace ChunkFooter::is_empty with free function#21772
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR refactors the arena allocator’s “empty chunk footer” sentinel check by removing the private ChunkFooter::is_empty method and introducing a free function that checks sentinel-ness via pointer equality, avoiding reference conversions solely for comparison.
Changes:
- Removed
ChunkFooter::is_empty(&self)and addedis_empty_footer(NonNull<ChunkFooter>)inarena/mod.rs. - Updated chunk-walking/reset/drop/allocation code paths to use
is_empty_footerinstead of deref + method calls. - Reduced unnecessary
NonNull::as_ref()usage in iterator/byte-counting logic when only sentinel checks are needed.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/oxc_allocator/src/arena/mod.rs | Replaces the ChunkFooter::is_empty method with the is_empty_footer free function based on pointer equality to the canonical sentinel. |
| crates/oxc_allocator/src/arena/drop.rs | Updates reset, chunk list deallocation, and related assertions to use is_empty_footer. |
| crates/oxc_allocator/src/arena/chunks.rs | Refactors chunk iteration and used_bytes/allocated_bytes logic to check sentinel via is_empty_footer before dereferencing. |
| crates/oxc_allocator/src/arena/alloc_impl.rs | Uses is_empty_footer to avoid touching the static empty footer’s interior mutability (prevents potential data race) without needing a ref conversion to check emptiness. |
cd3bb51 to
efe454e
Compare
80a6c06 to
b8065a7
Compare
Merge activity
|
…on (#21772) Remove `ChunkFooter::is_empty` method and add an `is_empty_footer` free function instead. This is beneficial as it removes the need for unsafe pointer to reference conversions.
efe454e to
7896bd0
Compare
b8065a7 to
f8422e2
Compare

Remove
ChunkFooter::is_emptymethod and add anis_empty_footerfree function instead. This is beneficial as it removes the need for unsafe pointer to reference conversions.