-
-
Notifications
You must be signed in to change notification settings - Fork 22k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move StringName !=
operator to the header file to make it inlineable.
#99815
Move StringName !=
operator to the header file to make it inlineable.
#99815
Conversation
Idk about operators, but at least functions with -O2 optimization level will be inlined by compiler if it is needed even without inline attribute. At least as far as I remember. So this one will make difference only for Godot Web builds which use -Os. |
This is not the case if the function is defined inside a module. In this case the function is considered to be blackbox, and a call is unavoidable. It may still be inlined by the LTO later, although not all release builds of Godot have LTO enabled. Plus, when it's LTO's turn, a lot of optimizations are already over. |
fd7375d
to
862006f
Compare
The change makes sense, I don't see a reason why |
862006f
to
a47d29c
Compare
!=
operator to the header file to make it inlineable.
Thanks! |
Small inconsistency I came across in my string endeavours. Shouldn't make a big difference, but it will make a small one, probably even with LTO enabled.
By allowing the function to be inlined, the compiler is allowed to reason about the code instead of having to make a Blackbox call, and surrounding code unlocks a whole slew of possible optimizations.
Notice how
operator==
is already in the header file right above the new!=
entry, ready to be inlined.