3 ms·
Yeah, same for enums in Swift. Although with classes in Swift it's not quite like a runtime GC. Static code is inserted to retain and release. Afaik the arc opt
by zer0zzz 4y ago
Yeah, same for enums in Swift. Although with classes in Swift it's not quite like a runtime GC. Static code is inserted to retain and release. Afaik the arc optimizer uses an ownership model to optimize placement of retain/releases.
I have been out of C# programming for over a decade now, but in Swift most guidance actually discourage use of classes, while a lot of types in the stdlib use a "Copy on Write" pattern where a struct contains a class that acts as a backing store. This gives the type value semantics but guarantees assignments will be cheap, only when the backing data is modified and the reference count is not unique is the data copied.