Commit 7f3dc04
committed
Auto merge of #87150 - rusticstuff:simplify_wrapping_neg, r=m-ou-se
Make wrapping_neg() use wrapping_sub(), #[inline(always)]
This is a follow-up change to the fix for #75598. It simplifies the implementation of wrapping_neg() for all integer types by just calling 0.wrapping_sub(self) and always inlines it. This leads to much less assembly code being emitted for opt-level≤1 and thus much better performance for debug-compiled code.
Background is [this discussion on the internals forum](https://internals.rust-lang.org/t/why-does-rust-generate-10x-as-much-unoptimized-assembly-as-gcc/14930).2 files changed
+4
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1132 | 1132 | | |
1133 | 1133 | | |
1134 | 1134 | | |
1135 | | - | |
| 1135 | + | |
1136 | 1136 | | |
1137 | | - | |
| 1137 | + | |
1138 | 1138 | | |
1139 | 1139 | | |
1140 | 1140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1246 | 1246 | | |
1247 | 1247 | | |
1248 | 1248 | | |
1249 | | - | |
| 1249 | + | |
1250 | 1250 | | |
1251 | | - | |
| 1251 | + | |
1252 | 1252 | | |
1253 | 1253 | | |
1254 | 1254 | | |
| |||
0 commit comments