2025-02-13 09:51 AM
Hi I was wondering what the best method is to change screens programatically. I saw
application().gotoXScreenNoTransition()
and also
static_cast<FrontendApplication*>(Application::getInstance())->gotoXScreenNoTransition();
Is there any difference in efficiency for the program?
2025-02-17 04:35 AM
Hello @Priyank ,
The 2 methods are similar in efficiency (technically slightly more efficient to go for application().gotoXScreenNoTransition() but this is very negligeable).
The difference is that the method application().gotoXScreenNoTransition() is simpler, more readable, and type-safe if application() returns the correct type directly.
On the other hand, static_cast<FrontendApplication*>(Application::getInstance())->gotoXScreenNoTransition() allows casting to a more specific type, which is useful if Application::getInstance() returns a base class pointer and you need to access derived class methods.
Regards,