Fast compilation time. Should the `final` keyword increase or decrease compilation time?

Explicitly declaring the final classes and making sure that the private material is annotated as such an increase or decrease in compilation time? I understand how this affects runtime by reducing dynamic dispatch.

Anecdotally, I tried this on a medium-sized project (and turned on the default Xcode values ​​for printing compile time), and compilation time surprisingly increased (by 8 seconds). Isn't it easier to understand how all the code comes along with hints that eliminate subclasses?

+5
source share
1 answer

The final keyword, if my understanding is correct, prohibits modifying a variable, making it constant. This should, in fact, reduce the number of possible optimizations that the compiler can perform during compilation, which should reduce the time spent compiling the program.

-4
source

Source: https://habr.com/ru/post/1247291/


All Articles