Commit f0ff31f
authored
Rollup merge of rust-lang#100169 - WaffleLapkin:optimize_is_aligned_to, r=workingjubilee
Optimize `pointer::as_aligned_to`
This PR replaces `addr % align` with `addr & align - 1`, which is correct due to `align` being a power of two.
Here is a proof that this makes things better: [[godbolt]](https://godbolt.org/z/Wbq3hx6YG).
This PR also removes `assume(align != 0)`, with the new impl it does not improve anything anymore ([[godbolt]](https://rust.godbolt.org/z/zcnrG4777), [[original concern]](rust-lang#95643 (comment))).2 files changed
+2
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1336 | 1336 | | |
1337 | 1337 | | |
1338 | 1338 | | |
1339 | | - | |
1340 | | - | |
1341 | | - | |
1342 | 1339 | | |
1343 | | - | |
| 1340 | + | |
1344 | 1341 | | |
1345 | 1342 | | |
1346 | 1343 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1614 | 1614 | | |
1615 | 1615 | | |
1616 | 1616 | | |
1617 | | - | |
1618 | | - | |
1619 | | - | |
1620 | 1617 | | |
1621 | | - | |
| 1618 | + | |
1622 | 1619 | | |
1623 | 1620 | | |
1624 | 1621 | | |
| |||
0 commit comments