How does Swift COW manage to avoid a dictionary copy in this simple computed property example?

Yes. Eliminating that overhead is a large part of the purpose of _read and _modify. I would also like to make it possible to conveniently declare storage as an alias for some other piece of storage, which would amount to defining _read and _modify automatically, but that's separable.

Although I don't know why you'd trivially wrap your own private property this way; it feels like importing the idiom of a different language.

2 Likes