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

@ -2218,13 +2218,12 @@ void RenderingDeviceGraph::add_synchronization() {
}
}
void RenderingDeviceGraph::begin_label(const String &p_label_name, const Color &p_color) {
void RenderingDeviceGraph::begin_label(const Span<char> &p_label_name, const Color &p_color) {
uint32_t command_label_offset = command_label_chars.size();
PackedByteArray command_label_utf8 = p_label_name.to_utf8_buffer();
int command_label_utf8_size = command_label_utf8.size();
command_label_chars.resize(command_label_offset + command_label_utf8_size + 1);
memcpy(&command_label_chars[command_label_offset], command_label_utf8.ptr(), command_label_utf8.size());
command_label_chars[command_label_offset + command_label_utf8_size] = '\0';
int command_label_size = p_label_name.size();
command_label_chars.resize(command_label_offset + command_label_size + 1);
memcpy(&command_label_chars[command_label_offset], p_label_name.ptr(), command_label_size);
command_label_chars[command_label_offset + command_label_size] = '\0';
command_label_colors.push_back(p_color);
command_label_offsets.push_back(command_label_offset);
command_label_index = command_label_count;