Swift begins by compiling a single implementation that performs dynamic type checking, but the optimizer can then choose to clone specialized implementations for certain types when it makes sense to compromise between speed sizes and code sizes. Ideally, this gets 90% acceleration of always cloning, without changing the size of the code or compilation time.
source share