summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-10-17 09:28:04 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-10-17 10:15:22 +0200
commit4a366fcfee24b3a5a5045b16c3b87b76147adf5e (patch)
tree7a8562579346a5dedb31137c896b6f5311ec061c /common
parent083311d0336ced35909b3375950f7817ecf95ed0 (diff)
Prevent stale content in Fast Render Mode
We do that by re-render visited pages that is not already in the stack. This may potentially do some double work, but that small penalty should be well worth it. Fixes #5281
Diffstat (limited to 'common')
-rw-r--r--common/types/evictingqueue.go7
-rw-r--r--common/types/evictingqueue_test.go3
2 files changed, 10 insertions, 0 deletions
diff --git a/common/types/evictingqueue.go b/common/types/evictingqueue.go
index 152dc4c41..884762426 100644
--- a/common/types/evictingqueue.go
+++ b/common/types/evictingqueue.go
@@ -52,6 +52,13 @@ func (q *EvictingStringQueue) Add(v string) {
q.mu.Unlock()
}
+// Contains returns whether the queue contains v.
+func (q *EvictingStringQueue) Contains(v string) bool {
+ q.mu.Lock()
+ defer q.mu.Unlock()
+ return q.set[v]
+}
+
// Peek looks at the last element added to the queue.
func (q *EvictingStringQueue) Peek() string {
q.mu.Lock()
diff --git a/common/types/evictingqueue_test.go b/common/types/evictingqueue_test.go
index a33f1a344..a7b1e1d54 100644
--- a/common/types/evictingqueue_test.go
+++ b/common/types/evictingqueue_test.go
@@ -36,6 +36,9 @@ func TestEvictingStringQueue(t *testing.T) {
queue.Add("a")
queue.Add("b")
+ assert.True(queue.Contains("a"))
+ assert.False(queue.Contains("foo"))
+
assert.Equal([]string{"b", "a"}, queue.PeekAll())
assert.Equal("b", queue.Peek())
queue.Add("c")