From 5cfacc876796324d2d06c83c83f1a128b9687b9a Mon Sep 17 00:00:00 2001 From: Stuart Carnie Date: Thu, 12 Sep 2024 06:19:24 +1000 Subject: [PATCH] [Editor,Servers]: Minor optimizations --- editor/editor_inspector.cpp | 2 +- servers/audio_server.cpp | 2 +- servers/rendering/renderer_viewport.cpp | 7 ++++--- servers/rendering/rendering_device.cpp | 16 ++++++++-------- servers/rendering/rendering_server_default.cpp | 10 ++++------ 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 4a2c41bc9c2..da50ffc510b 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -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) { ae.move_down = memnew(Button); ae.move_down->set_icon(get_editor_theme_icon(SNAME("MoveDown"))); ae.move_down->connect(SceneStringName(pressed), callable_mp(this, &EditorInspectorArray::_move_element).bind(element_position, element_position + 2)); diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index e06079efe8e..5835ecfed0c 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -1487,7 +1487,7 @@ void AudioServer::init() { void AudioServer::update() { #ifdef DEBUG_ENABLED - if (EngineDebugger::is_profiling("servers")) { + if (EngineDebugger::is_profiling(SNAME("servers"))) { // Driver time includes server time + effects times // Server time includes effects times uint64_t driver_time = AudioDriver::get_singleton()->get_profiling_time(); diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index 7e45eba1de5..781d29ffaa4 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -818,8 +818,9 @@ void RendererViewport::draw_viewports(bool p_swap_buffers) { blit.dst_rect.size = vp->size; } - if (!blit_to_screen_list.has(vp->viewport_to_screen)) { - blit_to_screen_list[vp->viewport_to_screen] = Vector(); + Vector *blits = blit_to_screen_list.getptr(vp->viewport_to_screen); + if (blits == nullptr) { + blits = &blit_to_screen_list.insert(vp->viewport_to_screen, Vector())->value; } if (OS::get_singleton()->get_current_rendering_driver_name().begins_with("opengl3")) { @@ -828,7 +829,7 @@ void RendererViewport::draw_viewports(bool p_swap_buffers) { RSG::rasterizer->blit_render_targets_to_screen(vp->viewport_to_screen, blit_to_screen_vec.ptr(), 1); RSG::rasterizer->gl_end_frame(p_swap_buffers); } else { - blit_to_screen_list[vp->viewport_to_screen].push_back(blit); + blits->push_back(blit); } } } diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp index 276cb4b210c..e322bba7687 100644 --- a/servers/rendering/rendering_device.cpp +++ b/servers/rendering/rendering_device.cpp @@ -138,17 +138,17 @@ RenderingDevice::ShaderSPIRVGetCacheKeyFunction RenderingDevice::get_spirv_cache /***************************/ void RenderingDevice::_add_dependency(RID p_id, RID p_depends_on) { - if (!dependency_map.has(p_depends_on)) { - dependency_map[p_depends_on] = HashSet(); + HashSet *set = dependency_map.getptr(p_depends_on); + if (set == nullptr) { + set = &dependency_map.insert(p_depends_on, HashSet())->value; } + set->insert(p_id); - dependency_map[p_depends_on].insert(p_id); - - if (!reverse_dependency_map.has(p_id)) { - reverse_dependency_map[p_id] = HashSet(); + set = reverse_dependency_map.getptr(p_id); + if (set == nullptr) { + set = &reverse_dependency_map.insert(p_id, HashSet())->value; } - - reverse_dependency_map[p_id].insert(p_depends_on); + set->insert(p_depends_on); } void RenderingDevice::_free_dependencies(RID p_id) { diff --git a/servers/rendering/rendering_server_default.cpp b/servers/rendering/rendering_server_default.cpp index 86efccef9a9..b994ebf3374 100644 --- a/servers/rendering/rendering_server_default.cpp +++ b/servers/rendering/rendering_server_default.cpp @@ -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] != '>') { - if (print_gpu_profile_task_time.has(name)) { - print_gpu_profile_task_time[name] += time; - } else { - print_gpu_profile_task_time[name] = time; - } + if (print_gpu_profile_task_time.has(name)) { + print_gpu_profile_task_time[name] += time; + } else { + print_gpu_profile_task_time[name] = time; } }