Rollup merge of #122099 - Urgau:btreemap-inline-new, r=Amanieu
Add `#[inline]` to `BTreeMap::new` constructor This PR add the `#[inline]` attribute to `BTreeMap::new` constructor as to make it eligible for inlining. <details> For some context: I was profiling `rustc --check-cfg` with callgrind and due to the way we currently setup all the targets and we end-up calling `BTreeMap::new` multiple times for (nearly) all the targets. Adding the `#[inline]` attribute reduced the number of instructions needed. </details>
This commit is contained in:
commit
d16c55d6f6
@ -624,6 +624,7 @@ impl<K, V> BTreeMap<K, V> {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_btree_new", since = "1.66.0")]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const fn new() -> BTreeMap<K, V> {
|
||||
BTreeMap { root: None, length: 0, alloc: ManuallyDrop::new(Global), _marker: PhantomData }
|
||||
|
Loading…
Reference in New Issue
Block a user