Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Document that cloning a `SecondaryMap`'s default value should not allocate (#12667)

Nick Fitzgeraldccfd33b495b7
diff --git a/crates/environ/src/collections/secondary_map.rs b/crates/environ/src/collections/secondary_map.rs
index 1ceb052792..d9e91de07d 100644
--- a/crates/environ/src/collections/secondary_map.rs
+++ b/crates/environ/src/collections/secondary_map.rs
@@ -27,6 +27,8 @@ where
V: Clone,
{
/// Same as [`cranelift_entity::SecondaryMap::new`].
+ ///
+ /// XXX: `Clone::clone(&<V as Default>::default())` should never allocate.
pub fn new() -> Self
where
V: Default,
@@ -37,6 +39,8 @@ where
}
/// Same as [`cranelift_entity::SecondaryMap::try_with_capacity`].
+ ///
+ /// XXX: `Clone::clone(&<V as Default>::default())` should never allocate.
pub fn with_capacity(capacity: usize) -> Result<Self, OutOfMemory>
where
V: Default,
@@ -47,6 +51,8 @@ where
}
/// Same as [`cranelift_entity::SecondaryMap::with_default`].
+ ///
+ /// XXX: `Clone::clone(&default)` should never allocate.
pub fn with_default(default: V) -> Self {
Self {
inner: Inner::with_default(default),