Skip to content

Commit 6c18e50

Browse files
dotdashthestinger
authored andcommitted
Make MIN_ALIGN a const to allow better optimization
With MIN_ALIGN as a static, other crates don't have access to its value at compile time, because it is an extern global. That means that the checks against it can't be optimized out, which is rather unfortunate. So let's make it a constant instead.
1 parent a10917a commit 6c18e50

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/liballoc/heap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ unsafe fn exchange_free(ptr: *mut u8, size: uint, align: uint) {
112112
#[cfg(any(target_arch = "arm",
113113
target_arch = "mips",
114114
target_arch = "mipsel"))]
115-
static MIN_ALIGN: uint = 8;
115+
const MIN_ALIGN: uint = 8;
116116
#[cfg(any(target_arch = "x86",
117117
target_arch = "x86_64"))]
118-
static MIN_ALIGN: uint = 16;
118+
const MIN_ALIGN: uint = 16;
119119

120120
#[cfg(jemalloc)]
121121
mod imp {

0 commit comments

Comments
 (0)