Terminal: Make sure empty hrefs set a null string on Attribute

Else, we store an empty but allocated string for each Attribute after a
href was emitted (since it's ended by a non-null empty string), which
makes Line objects very expensive to destroy and to modify.

Reduces `disasm /bin/id` from 414ms to 380ms (min-of-5). There's
a lot more perf wins to be had with better href handling (most
lines don't have any hrefs, so instead of storing a string per
Attr, maybe we could have a vector of hrefs per line and int offsets
into that in each Attr for example), but this is a simple, obvious,
and effective improvement, so let's start with this.
This commit is contained in:
Nico Weber 2020-09-12 21:02:57 -04:00 committed by Andreas Kling
parent 063fb02ef4
commit a6734766ec
Notes: sideshowbarker 2024-07-19 02:42:50 +09:00

View file

@ -576,9 +576,14 @@ void Terminal::execute_xterm_command()
m_client.set_window_title(params[1]);
break;
case 8:
m_current_attribute.href = params[2];
// FIXME: Respect the provided ID
m_current_attribute.href_id = String::format("%u", m_next_href_id++);
if (params[2].is_empty()) {
m_current_attribute.href = String();
m_current_attribute.href_id = String();
} else {
m_current_attribute.href = params[2];
// FIXME: Respect the provided ID
m_current_attribute.href_id = String::format("%u", m_next_href_id++);
}
break;
case 9:
m_client.set_window_progress(numeric_params[1], numeric_params[2]);