Commit b31ab01
authored
Unrolled build for #155778
Rollup merge of #155778 - kevinheavey:perf-mk-place-elem-avoid-vec-alloc, r=cjgillot,JohnTitor
Avoid Vec allocation in TyCtxt::mk_place_elem
`mk_place_elem` appends a single `PlaceElem` to an existing (interned) projection. The current implementation copies the projection into a fresh `Vec`, pushes the new element, and re-interns the slice, which allocates on every call.
Feed the elements through `mk_place_elems_from_iter` so that `CollectAndApply`'s hand-unrolled stack fast path (up to 9 elements, in `rustc_type_ir::interner`) kicks in for the common case of short projections and the `Vec` allocation is skipped entirely. The behavior is identical for longer projections (the fast path falls back to a `Vec` internally).1 file changed
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2416 | 2416 | | |
2417 | 2417 | | |
2418 | 2418 | | |
2419 | | - | |
2420 | | - | |
2421 | | - | |
2422 | | - | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
2423 | 2423 | | |
2424 | 2424 | | |
2425 | 2425 | | |
| |||
0 commit comments