-
Unlike C++, it is not necessary to designate that a method is virtual in Swift. The compiler will work out which of the following to use:
(the performance metrics of course depend on hardware)
- Inline the method : 0 ns
- Static dispatch: < 1.1ns
- Virtual dispatch 1.1ns (like Java, C# or C++ when designated).
- Dynamic Dispatch 4.9ns (like Objective-C).
Objective-C of course always uses the latter.
https://stackoverflow.com/questions/24022172/does-swift-use-message-dispatch-for-methods/25438321