summaryrefslogtreecommitdiff
path: root/xA
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2024-11-12 16:19:44 +0100
committerPřemysl Eric Janouch <p@janouch.name>2024-11-12 16:19:53 +0100
commit214c3498692cc7d81e233fcf6c27dccf448ab591 (patch)
tree07bea26f678646fe4a9d6d6382acf29960484a6d /xA
parent3d975c9437aaa2939c3179588fcc047ecaa768d7 (diff)
downloadxK-214c3498692cc7d81e233fcf6c27dccf448ab591.tar.gz
xK-214c3498692cc7d81e233fcf6c27dccf448ab591.tar.xz
xK-214c3498692cc7d81e233fcf6c27dccf448ab591.zip
xA: limit buffer length
Diffstat (limited to 'xA')
-rw-r--r--xA/xA.go17
1 files changed, 14 insertions, 3 deletions
diff --git a/xA/xA.go b/xA/xA.go
index e5f5ce8..cb6ede9 100644
--- a/xA/xA.go
+++ b/xA/xA.go
@@ -375,6 +375,17 @@ func bufferToggleUnimportant(name string) {
}, nil)
}
+func bufferPushLine(b *buffer, line bufferLine) {
+ b.lines = append(b.lines, line)
+
+ // Fyne's text layouting is extremely slow.
+ // The limit could be made configurable,
+ // and we could use a ring buffer approach to storing the lines.
+ if len(b.lines) > 100 {
+ b.lines = slices.Delete(b.lines, 0, 1)
+ }
+}
+
// --- Current buffer ----------------------------------------------------------
func bufferToggleLogFinish(err string, response *RelayResponseDataBufferLog) {
@@ -755,7 +766,7 @@ func relayProcessBufferLine(b *buffer, m *RelayEventDataBufferLine) {
// Initial sync: skip all other processing, let highlights be.
bc := bufferByName(bufferCurrent)
if bc == nil {
- b.lines = append(b.lines, line)
+ bufferPushLine(b, line)
return
}
@@ -767,7 +778,7 @@ func relayProcessBufferLine(b *buffer, m *RelayEventDataBufferLine) {
separate := display &&
!visible && bc.newMessages == 0 && bc.newUnimportantMessages == 0
- b.lines = append(b.lines, line)
+ bufferPushLine(b, line)
if !(visible || m.LeakToActive) ||
b.newMessages != 0 || b.newUnimportantMessages != 0 {
if line.isUnimportant || m.LeakToActive {
@@ -780,7 +791,7 @@ func relayProcessBufferLine(b *buffer, m *RelayEventDataBufferLine) {
if m.LeakToActive {
leakedLine := line
leakedLine.leaked = true
- bc.lines = append(bc.lines, leakedLine)
+ bufferPushLine(bc, leakedLine)
if !visible || bc.newMessages != 0 || bc.newUnimportantMessages != 0 {
if line.isUnimportant {