| ... | ... | @@ -475,7 +475,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 475 | 475 | if (aligned_size > largest_bucket_object_size) { |
| 476 | 476 | return self.resizeLarge(old_mem, old_align, new_size, len_align, ret_addr); |
| 477 | 477 | } |
| 478 | | const size_class_hint = up_to_nearest_power_of_2(usize, aligned_size); |
| 478 | const size_class_hint = math.ceilPowerOfTwoAssert(usize, aligned_size); |
| 479 | 479 | |
| 480 | 480 | var bucket_index = math.log2(size_class_hint); |
| 481 | 481 | var size_class: usize = size_class_hint; |
| ... | ... | @@ -512,7 +512,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 512 | 512 | return @as(usize, 0); |
| 513 | 513 | } |
| 514 | 514 | const new_aligned_size = math.max(new_size, old_align); |
| 515 | | const new_size_class = up_to_nearest_power_of_2(usize, new_aligned_size); |
| 515 | const new_size_class = math.ceilPowerOfTwoAssert(usize, new_aligned_size); |
| 516 | 516 | if (new_size_class <= size_class) { |
| 517 | 517 | return new_size; |
| 518 | 518 | } |
| ... | ... | @@ -553,7 +553,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 553 | 553 | |
| 554 | 554 | return slice; |
| 555 | 555 | } else { |
| 556 | | const new_size_class = up_to_nearest_power_of_2(usize, new_aligned_size); |
| 556 | const new_size_class = math.ceilPowerOfTwoAssert(usize, new_aligned_size); |
| 557 | 557 | const ptr = try self.allocSlot(new_size_class, ret_addr); |
| 558 | 558 | return ptr[0..len]; |
| 559 | 559 | } |
| ... | ... | @@ -586,13 +586,6 @@ const TraceKind = enum { |
| 586 | 586 | free, |
| 587 | 587 | }; |
| 588 | 588 | |
| 589 | | fn up_to_nearest_power_of_2(comptime T: type, n: T) T { |
| 590 | | var power: T = 1; |
| 591 | | while (power < n) |
| 592 | | power *= 2; |
| 593 | | return power; |
| 594 | | } |
| 595 | | |
| 596 | 589 | fn hash_addr(addr: usize) u32 { |
| 597 | 590 | if (@sizeOf(usize) == @sizeOf(u32)) |
| 598 | 591 | return addr; |