aboutsummaryrefslogtreecommitdiffstats
path: root/cache/bug_cache.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-08-23 19:11:38 +0200
committerMichael Muré <batolettre@gmail.com>2018-08-23 19:15:50 +0200
commit16f55e3f4d560330a638986130d27fd067300169 (patch)
tree41cfedb5c11bf9accd131d34b8a9ac25cfafaa05 /cache/bug_cache.go
parent6d7dc465d881d0d04b01dfb6e09870346216d2d0 (diff)
downloadgit-bug-16f55e3f4d560330a638986130d27fd067300169.tar.gz
bug: introduce WithSnapshot to maintain incrementally and effitiently a snapshot
Diffstat (limited to 'cache/bug_cache.go')
-rw-r--r--cache/bug_cache.go31
1 files changed, 3 insertions, 28 deletions
diff --git a/cache/bug_cache.go b/cache/bug_cache.go
index 59c39f5c..f0fc7ff6 100644
--- a/cache/bug_cache.go
+++ b/cache/bug_cache.go
@@ -9,7 +9,6 @@ import (
type BugCacher interface {
Snapshot() *bug.Snapshot
- ClearSnapshot()
// Mutations
AddComment(message string) error
@@ -25,27 +24,18 @@ type BugCacher interface {
type BugCache struct {
repo repository.Repo
- bug *bug.Bug
- snap *bug.Snapshot
+ bug *bug.WithSnapshot
}
func NewBugCache(repo repository.Repo, b *bug.Bug) BugCacher {
return &BugCache{
repo: repo,
- bug: b,
+ bug: &bug.WithSnapshot{Bug: b},
}
}
func (c *BugCache) Snapshot() *bug.Snapshot {
- if c.snap == nil {
- snap := c.bug.Compile()
- c.snap = &snap
- }
- return c.snap
-}
-
-func (c *BugCache) ClearSnapshot() {
- c.snap = nil
+ return c.bug.Snapshot()
}
func (c *BugCache) AddComment(message string) error {
@@ -60,9 +50,6 @@ func (c *BugCache) AddCommentWithFiles(message string, files []util.Hash) error
operations.CommentWithFiles(c.bug, author, message, files)
- // TODO: perf --> the snapshot could simply be updated with the new op
- c.ClearSnapshot()
-
return nil
}
@@ -77,9 +64,6 @@ func (c *BugCache) ChangeLabels(added []string, removed []string) error {
return err
}
- // TODO: perf --> the snapshot could simply be updated with the new op
- c.ClearSnapshot()
-
return nil
}
@@ -91,9 +75,6 @@ func (c *BugCache) Open() error {
operations.Open(c.bug, author)
- // TODO: perf --> the snapshot could simply be updated with the new op
- c.ClearSnapshot()
-
return nil
}
@@ -105,9 +86,6 @@ func (c *BugCache) Close() error {
operations.Close(c.bug, author)
- // TODO: perf --> the snapshot could simply be updated with the new op
- c.ClearSnapshot()
-
return nil
}
@@ -119,9 +97,6 @@ func (c *BugCache) SetTitle(title string) error {
operations.SetTitle(c.bug, author, title)
- // TODO: perf --> the snapshot could simply be updated with the new op
- c.ClearSnapshot()
-
return nil
}