Large collections in structs
You need to put a very large Dictionary, hundreds of thousands of entries, into a struct property and pass that struct around by value. What's the 'fastest' way to store and pass it?
You need to put a very large Dictionary, hundreds of thousands of entries, into a struct property and pass that struct around by value. What's the 'fastest' way to store and pass it?
Dictionary is a COW container, so putting it in a struct and copying only shares the heap buffer and bumps a reference count (O(1)). Just store it and pass it by value.
Memory and ARCShort answerAdvanced
How far is it true that "using a struct means no ARC cost"?
#cow #value-type #performance
SwiftShort answerBasics
In Swift, what's the fundamental difference between a struct and a class?
#cow #value-type
SwiftShort answerExpert
You need a struct ImageBuffer that wraps a large pixel buffer, keeps value semantics, and…
#cow #performance
SwiftMultiple choiceBasics
Which statements about Swift's inout parameters (func bump(_ x: inout Int)) are correct?…
#value-type #inout