Skip to content

Commit b6f985c

Browse files
committed
perf: change size_to_class to inline(always) for hot path
The size_to_class function is called on every alloc and dealloc. Changing from #[inline] to #[inline(always)] ensures it's always inlined, eliminating function call overhead and allowing the LUT lookup to be optimized with the surrounding code.
1 parent ff0e8a4 commit b6f985c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

aethalloc-abi/src/global.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ impl ThreadMetrics {
388388
/// and bit math on the most common allocation sizes.
389389
/// Maps: 16→0, 32→1, 64→2, 128→3, 256→4, 512→5, 1024→6, 2048→7,
390390
/// 4096→8, 8192→9, 16384→10, 32768→11, 65536→12
391-
#[inline]
391+
#[inline(always)]
392392
fn size_to_class(size: usize) -> Option<usize> {
393393
if size == 0 || size > 65536 {
394394
return None;

0 commit comments

Comments
 (0)