-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Optimize comparisons for Object's get_argument_options
#86743
Optimize comparisons for Object's get_argument_options
#86743
Conversation
As discussed in RocketChat, I'm not sure what the better approach is anymore. Doing this, having |
I think a faster way would be to compare |
|
Despite this being an optimization, I am not too concerned on performance. It's an editor-exclusive method called once in a while. This is more-so done for consistency and future-proofing if or when more autocompletion options are added. |
Maybe an option with code generation is possible?
The tricky part is how to split the names into multiple |
Definitely out of the scope of this PR, but do discuss it with other people more savvy about it, because it does sound neat in theory. |
I have attempted to do some "StringName optimizations" multiple times. E.g. the editor theme uses Strings everywhere for methods that take StringNames, so I though that it's inefficient and made reusable StringName variables. The result was that the code speed was the same, or even slower. It did not improve performance, at most it made binary size smaller. You can check my changes here: KoBeWi@124684a |
Hearing that makes my push towards String & StringName having the same methods on the outside feel all the more justified. Still, it's a bit disheartening to hear. Or, perhaps we shouldn't feel so bad, as the compiler does such a good job optimizing... strings? Who knows. |
0cc5567
to
af8c9e6
Compare
I will probably update this PR to surround all of these with TOOLS_ENABLED, although the PR is good as is, too. |
af8c9e6
to
290ce3a
Compare
290ce3a
to
9bafd2d
Compare
Done what I said I'd do... Is this really worth the review of all of those teams above? |
ea18076
to
9692910
Compare
9692910
to
cd2032a
Compare
For your interest see also #87197 |
Thanks! |
get_argument_options
get_argument_options
You could say it's a continuation of #86729 and #86733
I noticed that some
get_argument_options()
assign theirp_function
StringName into a normalpf
String before comparing the method's name. It turns out this is slightly better because it avoids the conversion every time, and sometimes it just... looks more readable.This PR makes that consistent across the board and gives a purpose to a lonely, unused
pf
in AnimationPlayer's method.One could question why
get_argument_options()
wants a StringName if it's better to just convert it back to String every time, but who am I to judge?I have a feeling this and the other previous PRs can be backported to 3.x, even(?).