Skip to content

Commit c1645f6

Browse files
committed
don't compute residue twice
1 parent 9b66527 commit c1645f6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/intptrcast.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,9 @@ impl<'mir, 'tcx> GlobalState {
108108
/// Shifts `addr` to make it aligned with `align` by rounding `addr` to the smallest multiple
109109
/// of `align` that is larger or equal to `addr`
110110
fn align_addr(addr: u64, align: u64) -> u64 {
111-
if addr % align == 0 {
112-
addr
113-
} else {
114-
addr + align - addr % align
111+
match addr % align {
112+
0 => addr,
113+
rem => addr + align - rem
115114
}
116115
}
117116
}

0 commit comments

Comments
 (0)