Understanding performance optimization
The first rule of optimization is—don't optimize. You should always remember this phrase by Donald Knut:
Premature optimization is the root of all evil
This is a very true and correct statement. You should start doing performance optimization only when you see a performance problem and you have found what is causing it.
There are two types of performance optimization:
Explicit
Implicit
Explicit
Explicit performance optimization is a technique that is directed at a specific slow piece of code. This type of optimization requires significant code changes that could worsen code readability. You do explicit performance optimization by changing the algorithm to a more effective one. Using more memory for the cache could also increase performance.
Implicit
Implicit performance optimization is the technique of applying language-specific, in our case Swift-specific, features that lead to better performance. Implicit code performance doesn't require significant code changes...