Description
We have a general Allocator
instance for &A
where A: Allocator
. I think that is a problem. In #98178 I fixed a problem where BTreeMap<T, Global>
would actually use &Global
as allocator, which leads to performance regression. Or at least, I thought I had fixed that problem -- I just realized that there are some places where it still adds an indirection and therefore adds an unnecessary reference that will be copied around:
rust/library/alloc/src/collections/btree/map.rs
Line 1647 in 3a1e114
I found this by removing the unsafe impl<A> Allocator for &A where A: Allocator + ?Sized
instance. I don't know of another way to avoid accidentally introducing such performance regressions.
So maybe that instance should be removed?
Cc @rust-lang/wg-allocators