-
-
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
[Editor, Servers] Minor optimizations #96875
[Editor, Servers] Minor optimizations #96875
Conversation
@@ -2246,7 +2246,7 @@ void EditorInspectorArray::_setup() { | |||
} | |||
move_vbox->add_child(ae.move_texture_rect); | |||
|
|||
if (element_position < _get_array_count() - 1) { | |||
if (element_position < count - 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Counts are cached at the top of the function:
godot/editor/editor_inspector.cpp
Lines 2164 to 2165 in 14a7e0a
// Setup counts. | |
count = _get_array_count(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only perform a single lookup in the hash table
@@ -150,12 +150,10 @@ void RenderingServerDefault::_draw(bool p_swap_buffers, double frame_step) { | |||
|
|||
double time = frame_profile[i + 1].gpu_msec - frame_profile[i].gpu_msec; | |||
|
|||
if (name[0] != '<' && name[0] != '>') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if
was redundant given the earlier check in the loop:
godot/servers/rendering/rendering_server_default.cpp
Lines 147 to 149 in 14a7e0a
if (name[0] == '<' || name[0] == '>') { | |
continue; | |
} |
if (!dependency_map.has(p_depends_on)) { | ||
dependency_map[p_depends_on] = HashSet<RID>(); | ||
HashSet<RID> *set = dependency_map.getptr(p_depends_on); | ||
if (set == nullptr) { | ||
set = &dependency_map.insert(p_depends_on, HashSet<RID>())->value; | ||
} | ||
set->insert(p_id); | ||
|
||
dependency_map[p_depends_on].insert(p_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The improvement removes a hash table lookup, as it calls getptr
to the value and only if it is nullptr
, does it insert it. Overall this function performs 2 less hash-table lookups per call.
1cd642a
to
5bc5d7a
Compare
5bc5d7a
to
5cfacc8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me!
Thanks! |
The PR introduces a few minor optimisations to prevent double look-ups in hash tables and removes some redundant checks.