Renderer: Eliminates String allocations for all labels in the renderer

Uses `Span<char>` to avoid additional allocations in the graph.
This commit is contained in:
Stuart Carnie 2025-05-23 06:52:10 +10:00
parent 6c9765d87e
commit 7d93119353
10 changed files with 30 additions and 19 deletions

View file

@ -6200,7 +6200,11 @@ void RenderingDevice::set_resource_name(RID p_id, const String &p_name) {
#endif
}
void RenderingDevice::draw_command_begin_label(String p_label_name, const Color &p_color) {
void RenderingDevice::_draw_command_begin_label(String p_label_name, const Color &p_color) {
draw_command_begin_label(p_label_name.utf8().span(), p_color);
}
void RenderingDevice::draw_command_begin_label(const Span<char> p_label_name, const Color &p_color) {
ERR_RENDER_THREAD_GUARD();
if (!context->is_debug_utils_enabled()) {
@ -7450,7 +7454,7 @@ void RenderingDevice::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_resource_name", "id", "name"), &RenderingDevice::set_resource_name);
ClassDB::bind_method(D_METHOD("draw_command_begin_label", "name", "color"), &RenderingDevice::draw_command_begin_label);
ClassDB::bind_method(D_METHOD("draw_command_begin_label", "name", "color"), &RenderingDevice::_draw_command_begin_label);
#ifndef DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("draw_command_insert_label", "name", "color"), &RenderingDevice::draw_command_insert_label);
#endif