aboutsummaryrefslogtreecommitdiff
path: root/src/chat.cpp
diff options
context:
space:
mode:
authorDS <vorunbekannt75@web.de>2021-09-19 20:23:35 +0200
committerGitHub <noreply@github.com>2021-09-19 20:23:35 +0200
commite79d6154fc26b2a9bac242f0ac01ec785b5c53b1 (patch)
treeeb4587e1a83696f4e9d08531856a7170d019ae65 /src/chat.cpp
parent40ea4ddef1fe56dab9a1479302f0b2578b4b0ed5 (diff)
downloadminetest-e79d6154fc26b2a9bac242f0ac01ec785b5c53b1.tar.gz
minetest-e79d6154fc26b2a9bac242f0ac01ec785b5c53b1.tar.bz2
minetest-e79d6154fc26b2a9bac242f0ac01ec785b5c53b1.zip
Fix client-side performance of chat UI (#11612)
Diffstat (limited to 'src/chat.cpp')
-rw-r--r--src/chat.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/chat.cpp b/src/chat.cpp
index 162622abe..d8b577aab 100644
--- a/src/chat.cpp
+++ b/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