summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authordelthas <delthas@dille.cc>2022-04-20 18:31:19 +0200
committerdelthas <delthas@dille.cc>2022-04-20 18:31:19 +0200
commitc78a9bd9fa6294b8b86e645d77c5f8fd8384fac9 (patch)
tree8f65286b2db0e9308fd6157979aa2f32faeb3334 /ui
parentFix default highlight command path not being used (diff)
Defer parsing URLs until a buffer is opened at least once
This heavily reduces CPU load on start, so that we only parse the links of the current buffer hundreds of messages, rather than all of the hundreds of messages * count of buffers.
Diffstat (limited to 'ui')
-rw-r--r--ui/buffers.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/ui/buffers.go b/ui/buffers.go
index 553de9e..b94e21a 100644
--- a/ui/buffers.go
+++ b/ui/buffers.go
@@ -186,6 +186,7 @@ type buffer struct {
highlights int
unread bool
read time.Time
+ openedOnce bool
lines []Line
topic string
@@ -359,7 +360,7 @@ func (bs *BufferList) AddLine(netID, title string, notify NotifyType, line Line)
n := len(b.lines)
line.At = line.At.UTC()
- if !line.Mergeable {
+ if !line.Mergeable && current.openedOnce {
line.Body = line.Body.ParseURLs()
}
@@ -401,7 +402,9 @@ func (bs *BufferList) AddLines(netID, title string, before, after []Line) {
}
} else {
if buf != &b.lines {
- line.Body = line.Body.ParseURLs()
+ if b.openedOnce {
+ line.Body = line.Body.ParseURLs()
+ }
line.computeSplitPoints()
}
lines = append(lines, line)
@@ -686,6 +689,12 @@ func (bs *BufferList) DrawTimeline(screen tcell.Screen, x0, y0, nickColWidth int
clearArea(screen, x0, y0, bs.tlInnerWidth+nickColWidth+9, bs.tlHeight+2)
b := bs.cur()
+ if !b.openedOnce {
+ b.openedOnce = true
+ for i := 0; i < len(b.lines); i++ {
+ b.lines[i].Body = b.lines[i].Body.ParseURLs()
+ }
+ }
xTopic := x0
printString(screen, &xTopic, y0, Styled(b.topic, tcell.StyleDefault))