mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Fix client-side performance of chat UI (#11612)
This commit is contained in:
parent
40ea4ddef1
commit
e79d6154fc
5 changed files with 47 additions and 18 deletions
13
src/chat.cpp
13
src/chat.cpp
|
@ -50,6 +50,8 @@ ChatBuffer::ChatBuffer(u32 scrollback):
|
|||
|
||||
void ChatBuffer::addLine(const std::wstring &name, const std::wstring &text)
|
||||
{
|
||||
m_lines_modified = true;
|
||||
|
||||
ChatLine line(name, text);
|
||||
m_unformatted.push_back(line);
|
||||
|
||||
|
@ -72,6 +74,7 @@ void ChatBuffer::clear()
|
|||
m_unformatted.clear();
|
||||
m_formatted.clear();
|
||||
m_scroll = 0;
|
||||
m_lines_modified = true;
|
||||
}
|
||||
|
||||
u32 ChatBuffer::getLineCount() const
|
||||
|
@ -99,14 +102,11 @@ void ChatBuffer::deleteOldest(u32 count)
|
|||
u32 del_unformatted = 0;
|
||||
u32 del_formatted = 0;
|
||||
|
||||
while (count > 0 && del_unformatted < m_unformatted.size())
|
||||
{
|
||||
while (count > 0 && del_unformatted < m_unformatted.size()) {
|
||||
++del_unformatted;
|
||||
|
||||
// keep m_formatted in sync
|
||||
if (del_formatted < m_formatted.size())
|
||||
{
|
||||
|
||||
if (del_formatted < m_formatted.size()) {
|
||||
sanity_check(m_formatted[del_formatted].first);
|
||||
++del_formatted;
|
||||
while (del_formatted < m_formatted.size() &&
|
||||
|
@ -120,6 +120,9 @@ void ChatBuffer::deleteOldest(u32 count)
|
|||
m_unformatted.erase(m_unformatted.begin(), m_unformatted.begin() + del_unformatted);
|
||||
m_formatted.erase(m_formatted.begin(), m_formatted.begin() + del_formatted);
|
||||
|
||||
if (del_unformatted > 0)
|
||||
m_lines_modified = true;
|
||||
|
||||
if (at_bottom)
|
||||
m_scroll = getBottomScrollPos();
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue