From 1e62f2c8c454289e5e3becd31c2c8a12167d2e52 Mon Sep 17 00:00:00 2001 From: Feoramund <161657516+Feoramund@users.noreply.github.com> Date: Mon, 27 Jan 2025 19:41:22 -0500 Subject: [PATCH] Rearrange slab iteration conditionals --- base/runtime/heap_allocator_control.odin | 6 +++--- base/runtime/heap_allocator_implementation.odin | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/base/runtime/heap_allocator_control.odin b/base/runtime/heap_allocator_control.odin index 356e00477..737870c04 100644 --- a/base/runtime/heap_allocator_control.odin +++ b/base/runtime/heap_allocator_control.odin @@ -17,11 +17,11 @@ compact_superpage :: proc "contextless" (superpage: ^Heap_Superpage) -> (freed: if slab.bin_size > HEAP_MAX_BIN_SIZE { // Skip contiguous slabs. i += heap_slabs_needed_for_size(slab.bin_size) - } else if slab.bin_size > 0 { - i += 1 } else { i += 1 - continue + if slab.bin_size == 0 { + continue + } } slab_is_cached := slab.free_bins > 0 diff --git a/base/runtime/heap_allocator_implementation.odin b/base/runtime/heap_allocator_implementation.odin index 5e21bfa14..d7148d8d2 100644 --- a/base/runtime/heap_allocator_implementation.odin +++ b/base/runtime/heap_allocator_implementation.odin @@ -490,11 +490,11 @@ heap_cache_register_superpage :: proc "contextless" (superpage: ^Heap_Superpage) if slab.bin_size > HEAP_MAX_BIN_SIZE { // Skip contiguous slabs. i += heap_slabs_needed_for_size(slab.bin_size) - } else if slab.bin_size > 0 { - i += 1 } else { i += 1 - continue + if slab.bin_size == 0 { + continue + } } // When adopting a new Superpage, we take the opportunity to @@ -1274,11 +1274,11 @@ setup_superpage_orphanage :: proc "contextless" () { if slab.bin_size > HEAP_MAX_BIN_SIZE { // Skip contiguous slabs. i += heap_slabs_needed_for_size(slab.bin_size) - } else if slab.bin_size > 0 { - i += 1 } else { i += 1 - continue + if slab.bin_size == 0 { + continue + } } if intrinsics.atomic_load_explicit(&slab.remote_free_bins_scheduled, .Acquire) > 0 {