Commit bf60295
authored
Rollup merge of rust-lang#49555 - nox:inline-into-boxed, r=alexcrichton
Inline most of the code paths for conversions with boxed slices
This helps with the specific problem described in rust-lang#49541, obviously without making any large change to how inlining works in the general case.
Everything involved in the conversions is made `#[inline]`, except for the `<Vec<T>>::into_boxed_slice` entry point which is made `#[inline(always)]` after checking that duplicating the function mentioned in the issue prevented its inlining if I only annotate it with
`#[inline]`.
For the record, that function was:
```rust
pub fn foo() -> Box<[u8]> {
vec![0].into_boxed_slice()
}
```
To help the inliner's job, we also hoist a `self.capacity() != self.len` check in `<Vec<T>>::shrink_to_fit` and mark it as `#[inline]` too.4 files changed
+9
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
| 432 | + | |
432 | 433 | | |
433 | 434 | | |
434 | 435 | | |
435 | 436 | | |
436 | 437 | | |
437 | 438 | | |
438 | 439 | | |
| 440 | + | |
439 | 441 | | |
440 | 442 | | |
441 | 443 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1827 | 1827 | | |
1828 | 1828 | | |
1829 | 1829 | | |
| 1830 | + | |
1830 | 1831 | | |
1831 | 1832 | | |
1832 | 1833 | | |
| |||
2065 | 2066 | | |
2066 | 2067 | | |
2067 | 2068 | | |
| 2069 | + | |
2068 | 2070 | | |
2069 | 2071 | | |
2070 | 2072 | | |
| |||
2323 | 2325 | | |
2324 | 2326 | | |
2325 | 2327 | | |
| 2328 | + | |
2326 | 2329 | | |
2327 | 2330 | | |
2328 | 2331 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1586 | 1586 | | |
1587 | 1587 | | |
1588 | 1588 | | |
| 1589 | + | |
1589 | 1590 | | |
1590 | 1591 | | |
1591 | 1592 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
583 | 583 | | |
584 | 584 | | |
585 | 585 | | |
586 | | - | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
587 | 589 | | |
588 | 590 | | |
589 | 591 | | |
| |||
0 commit comments