mirror of
https://github.com/godotengine/godot.git
synced 2025-11-01 06:01:14 +00:00
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:
parent
6c9765d87e
commit
7d93119353
10 changed files with 30 additions and 19 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue