aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2024-01-06 23:27:22 +0100
committerPřemysl Eric Janouch <p@janouch.name>2024-01-06 23:44:11 +0100
commitef257cd5757fd6ae13d7639d6ed17dd779f173e3 (patch)
tree885aea98d23a9e078f6b1717f5ab27ad3ffb2b48
parent69eccc706593935395d362677b3219321c6eb853 (diff)
downloadxK-ef257cd5757fd6ae13d7639d6ed17dd779f173e3.tar.gz
xK-ef257cd5757fd6ae13d7639d6ed17dd779f173e3.tar.xz
xK-ef257cd5757fd6ae13d7639d6ed17dd779f173e3.zip
xP: avoid expensive updates/refreshes
-rw-r--r--xP/public/xP.js20
1 files changed, 16 insertions, 4 deletions
diff --git a/xP/public/xP.js b/xP/public/xP.js
index ea70bbd..d34ddf8 100644
--- a/xP/public/xP.js
+++ b/xP/public/xP.js
@@ -286,7 +286,6 @@ 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
}
@@ -302,7 +301,13 @@ rpcEventHandlers.set(Relay.Event.BufferLine, e => {
else
b.newMessages++
}
- bufferPopExcessLines(b)
+
+ // XXX: In its unkeyed diff algorithm, Mithril.js can only efficiently
+ // deal with common prefixes, i.e., indefinitely growing buffers.
+ // But we don't want to key all children of Buffer,
+ // so only trim buffers while they are, or once they become invisible.
+ if (e.bufferName != bufferCurrent)
+ bufferPopExcessLines(b)
if (e.leakToActive) {
let bc = buffers.get(bufferCurrent)
@@ -313,7 +318,6 @@ rpcEventHandlers.set(Relay.Event.BufferLine, e => {
else
bc.newMessages++
}
- bufferPopExcessLines(bc)
}
if (line.isHighlight || (!visible && !line.isUnimportant &&
@@ -370,8 +374,16 @@ rpcEventHandlers.set(Relay.Event.BufferRemove, e => {
rpcEventHandlers.set(Relay.Event.BufferActivate, e => {
let old = buffers.get(bufferCurrent)
- if (old !== undefined)
+ if (old !== undefined) {
bufferResetStats(old)
+ bufferPopExcessLines(old)
+ }
+
+ // Initial sync: trim all buffers to our limit, just for consistency.
+ if (bufferCurrent === undefined) {
+ for (let b of buffers.values())
+ bufferPopExcessLines(b)
+ }
bufferLast = bufferCurrent
let b = buffers.get(e.bufferName)