summaryrefslogtreecommitdiff
path: root/xP/public
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2024-01-06 21:07:03 +0100
committerPřemysl Eric Janouch <p@janouch.name>2024-01-06 21:17:18 +0100
commit69eccc706593935395d362677b3219321c6eb853 (patch)
tree373426eae07e13f4db58b266d87e89701480e1ee /xP/public
parent13d2ff115ba094380a25de50aa4e760a8f839103 (diff)
downloadxK-69eccc706593935395d362677b3219321c6eb853.tar.gz
xK-69eccc706593935395d362677b3219321c6eb853.tar.xz
xK-69eccc706593935395d362677b3219321c6eb853.zip
xP: don't let buffers grow indefinitely
Primarily for performance reasons.
Diffstat (limited to 'xP/public')
-rw-r--r--xP/public/xP.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/xP/public/xP.js b/xP/public/xP.js
index e4f5647..ea70bbd 100644
--- a/xP/public/xP.js
+++ b/xP/public/xP.js
@@ -197,6 +197,14 @@ function bufferResetStats(b) {
b.highlighted = false
}
+function bufferPopExcessLines(b) {
+ // Let "new" messages be, if only because pulling the log file
+ // is much more problematic in the web browser than in xC.
+ // TODO: Make the limit configurable, or extract general.backlog_limit.
+ const old = b.lines.length - b.newMessages - b.newUnimportantMessages
+ b.lines.splice(0, old - 1000)
+}
+
function bufferActivate(name) {
rpc.send({command: 'BufferActivate', bufferName: name})
}
@@ -278,6 +286,7 @@ rpcEventHandlers.set(Relay.Event.BufferLine, e => {
// Initial sync: skip all other processing, let highlights be.
if (bufferCurrent === undefined) {
b.lines.push(line)
+ bufferPopExcessLines(b)
return
}
@@ -293,6 +302,7 @@ rpcEventHandlers.set(Relay.Event.BufferLine, e => {
else
b.newMessages++
}
+ bufferPopExcessLines(b)
if (e.leakToActive) {
let bc = buffers.get(bufferCurrent)
@@ -303,6 +313,7 @@ rpcEventHandlers.set(Relay.Event.BufferLine, e => {
else
bc.newMessages++
}
+ bufferPopExcessLines(bc)
}
if (line.isHighlight || (!visible && !line.isUnimportant &&
@@ -336,7 +347,7 @@ rpcEventHandlers.set(Relay.Event.BufferStats, e => {
if (b === undefined)
return
- b.newMessages = e.newMessages,
+ b.newMessages = e.newMessages
b.newUnimportantMessages = e.newUnimportantMessages
b.highlighted = e.highlighted
})