Hmm… the WWDC talk starts with something like this:
struct S1 {
class C {
var x = 0
var y = 0
}
var c = C()
func increment() {
c.x += 1
c.y += 1
}
}
And migrates to something like this:
struct S2 {
var x = 0
var y = 0
mutating func increment() {
x += 1
y += 1
}
}
To reduce the calls to swift_beginAccess. My question was more along the lines of if we wanted to preserve the nested class as a reference type do we have any more options to help? Something like:
struct S3 {
private final class C {
var x = 0
var y = 0
}
private let c = C()
func increment() {
c.x += 1
c.y += 1
}
}
Do we know to what extent could private and final help the compiler optimize out those swift_beginAccess calls?