Skip to content

refactor(allocator): remove pointless debug_assert!s#21728

Merged
graphite-app[bot] merged 1 commit into
mainfrom
om/04-24-refactor_allocator_remove_pointless_debug_assert_s
Apr 24, 2026
Merged

refactor(allocator): remove pointless debug_assert!s#21728
graphite-app[bot] merged 1 commit into
mainfrom
om/04-24-refactor_allocator_remove_pointless_debug_assert_s

Conversation

@overlookmotel

@overlookmotel overlookmotel commented Apr 24, 2026

Copy link
Copy Markdown
Member

usize::is_power_of_two already returns false for 0, so this is pointless duplication:

debug_assert!(n > 0);
debug_assert!(n.is_power_of_two());

Remove the first debug_assert! in these cases, to reduce code size and improve perf in debug builds.

overlookmotel commented Apr 24, 2026

Copy link
Copy Markdown
Member Author

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codspeed-hq

codspeed-hq Bot commented Apr 24, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 48 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing om/04-24-refactor_allocator_remove_pointless_debug_assert_s (a717a55) with main (83b91f5)2

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (a717a55) during the generation of this report, so 83b91f5 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@overlookmotel overlookmotel self-assigned this Apr 24, 2026
@overlookmotel overlookmotel added C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior A-allocator Area - Allocator labels Apr 24, 2026
@overlookmotel
overlookmotel marked this pull request as ready for review April 24, 2026 19:39
Copilot AI review requested due to automatic review settings April 24, 2026 19:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors oxc_allocator arena utilities by removing redundant debug_assert!(divisor > 0) checks where debug_assert!(divisor.is_power_of_two()) already guarantees non-zero, reducing debug-build code size and minor overhead.

Changes:

  • Remove redundant debug_assert!(divisor > 0) from round_up_to, round_down_to, round_mut_ptr_down_to, and round_mut_ptr_up_to_unchecked.

@graphite-app

graphite-app Bot commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Merge activity

`usize::is_power_of_two` already returns `false` for `0`, so this is pointless duplication:

```rust
debug_assert!(n > 0);
debug_assert!(n.is_power_of_two());
```

Remove the first `debug_assert!` in these cases, to reduce code size and improve perf in debug builds.
@graphite-app
graphite-app Bot force-pushed the om/04-24-refactor_allocator_remove_pointless_debug_assert_s branch from 4aac05b to a717a55 Compare April 24, 2026 21:15
@graphite-app
graphite-app Bot merged commit a717a55 into main Apr 24, 2026
36 checks passed
@graphite-app
graphite-app Bot deleted the om/04-24-refactor_allocator_remove_pointless_debug_assert_s branch April 24, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-allocator Area - Allocator C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants