refactor(allocator): clarify max calculations in Arena#21796
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors oxc_allocator::arena::Arena alignment/size calculations to use std::cmp::max consistently and simplifies one chunk-alignment computation based on the existing MIN_ALIGN <= CHUNK_ALIGN invariant.
Changes:
- Replace chained
.max(...)calls withcmp::max(a, b)across allocator code and tests. - Simplify
new_chunkalignment computation to only considerrequested_layout.align()andCHUNK_ALIGN. - Update an arena allocation test to use
cmp::maxfor alignment expectations.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/oxc_allocator/tests/arena/alloc_fill.rs | Updates test alignment math to use cmp::max. |
| crates/oxc_allocator/src/arena/create.rs | Uses cmp::max and simplifies chunk alignment calculation in new_chunk. |
| crates/oxc_allocator/src/arena/alloc_impl.rs | Switches size/alignment max computations to cmp::max. |
Merging this PR will not alter performance
Comparing Footnotes
|
b56ad4b to
0423be8
Compare
87e8340 to
8fb23df
Compare
Merge activity
|
Small refactor to `Arena`. Use `cmp::max(a, b)` instead of the chained version `a.max(b)`. I find the former clearer. Also simplify one `max` operation (see comment in code).
0423be8 to
481b75f
Compare
8fb23df to
94a41eb
Compare

Small refactor to
Arena. Usecmp::max(a, b)instead of the chained versiona.max(b). I find the former clearer.Also simplify one
maxoperation (see comment in code).