Repository navigation
Conversation
These methods are of particular interest for users because they perform better due to specialization, e.g. when `elem` is zero. In that case, it will result in a call to `calloc` or equivalent, which is better than a call to `malloc` followed by `memset`. We also forward the existing `std::vec::from_elem` and `std::vec::from_elem_in` to these new associated methods on `Vec`. The module-level methods could potentially be removed in a follow-up.
| /// assert_eq!(vec, [0; 3]); | ||
| /// ``` | ||
| #[cfg(not(no_global_oom_handling))] | ||
| #[unstable(feature = "vec_from_elem", issue = "none")] |
There was a problem hiding this comment.
Is this part of an existing feature or should we create a new tracking issue for this? Also, should from_elem_in use the same feature or does it belong in allocator_ext?
There was a problem hiding this comment.
I would put both of these into their own from_elem issue since I have a feeling allocator_ext will get stabilised first. But yes, should have one.
This comment has been minimized.
This comment has been minimized.
|
r? ChrisDenton Offloading a few PRs, Chris should have enough context to handle this. |
This comment has been minimized.
This comment has been minimized.
|
I wouldn't be willing to support this without an accepted ACP that details the motivation. It is basically a new specialization wrapper (while it existed before, it was only for internal use). So I'll pass on review. r? libs |
|
Yup, this is major enough to need discussion as an ACP. @Gelbpunkt could you file one? |
Tracking issue: #164215
These methods are of particular interest for users because they perform better due to specialization, e.g. when
elemis zero. In that case, it will result in a call tocallocor equivalent, which is better than a call tomallocfollowed bymemset.We also forward the existing
std::vec::from_elemtoVec::from_elem. The old module-level methodstd::vec::from_elem_inwas unstable and unused, so I've removed it as per reviewer's request.Zulip thread
r? @clarfonthey