Remove some unnecessary string copies in TerminalUI
This commit is contained in:
parent
e3957bb24c
commit
63b67d0f31
|
@ -71,7 +71,7 @@ struct TerminalUI::Window::Line
|
||||||
friend size_t hash_value(const Atom& atom) { return hash_values(atom.text, atom.skip, atom.face); }
|
friend size_t hash_value(const Atom& atom) { return hash_values(atom.text, atom.skip, atom.face); }
|
||||||
};
|
};
|
||||||
|
|
||||||
void append(String text, ColumnCount skip, Face face)
|
void append(StringView text, ColumnCount skip, Face face)
|
||||||
{
|
{
|
||||||
if (not atoms.empty() and atoms.back().face == face and (atoms.back().skip == 0 or text.empty()))
|
if (not atoms.empty() and atoms.back().face == face and (atoms.back().skip == 0 or text.empty()))
|
||||||
{
|
{
|
||||||
|
@ -79,7 +79,7 @@ struct TerminalUI::Window::Line
|
||||||
atoms.back().skip += skip;
|
atoms.back().skip += skip;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
atoms.push_back({std::move(text), skip, face});
|
atoms.push_back({text.str(), skip, face});
|
||||||
}
|
}
|
||||||
|
|
||||||
void resize(ColumnCount width)
|
void resize(ColumnCount width)
|
||||||
|
@ -180,9 +180,9 @@ void TerminalUI::Window::draw(DisplayCoord pos,
|
||||||
|
|
||||||
auto face = merge_faces(default_face, atom.face);
|
auto face = merge_faces(default_face, atom.face);
|
||||||
if (content.back() == '\n')
|
if (content.back() == '\n')
|
||||||
lines[(int)pos.line].append(content.substr(0, content.length()-1).str(), 1, face);
|
lines[(int)pos.line].append(content.substr(0, content.length()-1), 1, face);
|
||||||
else
|
else
|
||||||
lines[(int)pos.line].append(content.str(), 0, face);
|
lines[(int)pos.line].append(content, 0, face);
|
||||||
pos.column += content.column_length();
|
pos.column += content.column_length();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user