3 ms·
Only "class" object is reference counted (to some extents, class-like objects too). Int / struct (value-semantics) objects are not reference counted. These are
by liuliu 1y ago
Only "class" object is reference counted (to some extents, class-like objects too). Int / struct (value-semantics) objects are not reference counted. These are copied eagerly.
Swift introduced bunch of ownership keywords to help you to use value objects for most of the needs to sidestep reference-counting and minimize copying.
Of course, to my understanding, "actor" in Swift is a "class"-like object, so it will be reference-counted. But I fail to see how that is different from other systems (as actor itself has to be mutable, hence, a reference object anyway).
- brandonasuncion 1y agoAnd for times you need a fast heap-allocated type, Swift's Noncopyable types have been pretty great in my experience. Especially so for graph data structures, where previously retains/releases would be the biggest slowdown. Example here: https://forums.swift.org/t/noncopyable-generics-in-swift-a-code-walkthrough/70862 https://forums.swift.org/t/noncopyable-generics-in-swift-a-c... An added plus is that the Swift compiler seems to stack-promote a lot more often, compared to class/ManagedBuffer implementations.