Creating a String requires a new allocation on the heap, where the string stores a full copy of its data. A SubString, because it refers to an existing String, only needs to store references, and therefore requires no heap allocation to create.
A SubString is essentially a pointer and two integers.
3 Likes