0Pricing
Swift Academy · Lesson

Performance notes — copy-on-write

Understand Swift String performance: copy-on-write (COW), substring sharing, and how to manage memory efficiently.

Intro

Goal: Learn how Strings use copy-on-write (COW) to balance performance and safety. Substrings also share memory until needed.

Shared storage

Assigning a String does not immediately copy characters. Both share the same storage.

var a = "Hello World"
var b = a            // no real copy yet
print(a, b)

All lessons in this course

  1. Strings & Unicode — graphemes, indices, substrings, APIs
  2. Common APIs — prefix/suffix/contains, split/join
  3. Performance notes — copy-on-write
← Back to Swift Academy