Add @immutable attribute for structs and enums

I have been using inout for structures with significant retain/release cost, after reading this response Stack-allocated collections - #9 by taylorswift I was under the impression, that the unsafe buffer is allocated on the stack.
Those were the two "workarounds" I am aware of.
In the past, I was also trying to dive into how Stack Promotion works ( discussed here for example Stack promotion of reference types ), but I gave up. I was wondering whether this optimization may reduce some of the COW retain/release costs if the compiler can prove that the values won't escape.

1 Like