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:
Matthias Krüger 2024-03-08 08:19:19 +01:00 committed by GitHub
commit d16c55d6f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 }