3 ms·
Swift already uses reference counting for memory management, so copy-on-write is basically free -- it just checks to see if the collection's reference count is
by NobodyNada 6y ago
Swift already uses reference counting for memory management, so copy-on-write is basically free -- it just checks to see if the collection's reference count is greater than 1 before writing.
- dmitriid 6y agoIt's decidedly not free. Reference counting in Swift can be (is?) a major bottleneck. See this project: https://github.com/ixy-languages/ixy-languages https://github.com/ixy-languages/ixy-languages and its discussion on Swift performance: https://github.com/ixy-languages/ixy.swift/blob/master/performance/README.md https://github.com/ixy-languages/ixy.swift/blob/master/perfo...
- NobodyNada 6y agoIt’s free since the language is already using reference counting. But yes, retain/release traffic is often a huge problem in performance-critical code.