2 ms·
Could easily just be a bad optimization pathway. `final` tells the compiler that nothing extends this class. That means the compiler can theoretically do thin
by cogman10 3y ago
Could easily just be a bad optimization pathway.
`final` tells the compiler that nothing extends this class. That means the compiler can theoretically do things like inlining class methods and eliminate virtual method calls (perhaps duplicating the method)?
However, it's quite possible that one of those optimizations makes the code bigger or misaligns things with the cache in unexpected ways. Sometimes, a method call can bet faster than inlining. Especially with hot loops.
All this being said, I'd expect final to offer very little benefit over PGO. Its main value is the constraint it imposes and not the optimization it might enable.