Skip to content

Commit 55e9de3

Browse files
committed
Auto merge of #122099 - Urgau:btreemap-inline-new, r=<try>
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>
2 parents bfe762e + cc38c1e commit 55e9de3

File tree

1 file changed

+1
-0
lines changed
  • library/alloc/src/collections/btree

1 file changed

+1
-0
lines changed

library/alloc/src/collections/btree/map.rs

+1
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ impl<K, V> BTreeMap<K, V> {
624624
/// ```
625625
#[stable(feature = "rust1", since = "1.0.0")]
626626
#[rustc_const_stable(feature = "const_btree_new", since = "1.66.0")]
627+
#[inline]
627628
#[must_use]
628629
pub const fn new() -> BTreeMap<K, V> {
629630
BTreeMap { root: None, length: 0, alloc: ManuallyDrop::new(Global), _marker: PhantomData }

0 commit comments

Comments
 (0)