xP: don't let buffers grow indefinitely
Primarily for performance reasons.
This commit is contained in:
parent
13d2ff115b
commit
69eccc7065
|
@ -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
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue