I think the biggest GC-related performance benefit of value types isn’t that you can allocate them on the stack, since a generational GC will easily eat up those allocations. It’s so that more *long-lived* data can become pointer-free and not scanned at all.
I don’t know of one. I’ve thought about such optimizations, but it seems hard, because the semantics of value vs. reference types are so different. Plus it would have to be a global optimization, which has problems with separate compilation, etc.
-
-
This might be a good candidate for a linter that tells you when your class could be a struct instead.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
If your data structures are acyclic and observably immutable, you can still have mutable bindings & make stack/heap tradeoffs based on object size or other concerns. As a bonus, can use an efficient delayed ref-counting technique and still have deep mutation when RC=1.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.