Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: impl/memory/gkvlite_utils.go

Issue 2498463003: Fix a bug where deletions weren't updating the raw Kind index. (Closed)
Patch Set: Fix Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: impl/memory/gkvlite_utils.go
diff --git a/impl/memory/gkvlite_utils.go b/impl/memory/gkvlite_utils.go
index 6c092040a1380214329790fcff2864c27bcd2059..cd96ab28e5cb1d0bb820f1a7a8ca233410563306 100644
--- a/impl/memory/gkvlite_utils.go
+++ b/impl/memory/gkvlite_utils.go
@@ -25,7 +25,6 @@ func gkvCollide(o, n memCollection, f func(k, ov, nv []byte)) {
oldItems, newItems := make(chan *gkvlite.Item), make(chan *gkvlite.Item)
walker := func(c memCollection, ch chan<- *gkvlite.Item, wg *sync.WaitGroup) {
defer close(ch)
- defer wg.Done()
if c != nil {
c.VisitItemsAscend(nil, true, func(i *gkvlite.Item) bool {
ch <- i
@@ -35,23 +34,24 @@ func gkvCollide(o, n memCollection, f func(k, ov, nv []byte)) {
}
wg := &sync.WaitGroup{}
iannucci 2016/11/12 00:05:47 del wg too?
- wg.Add(2)
go walker(o, oldItems, wg)
go walker(n, newItems, wg)
l, r := <-oldItems, <-newItems
for {
- if l == nil && r == nil {
- break
- }
+ switch {
+ case l == nil && r == nil:
+ return
- if l == nil {
+ case l == nil:
f(r.Key, nil, r.Val)
r = <-newItems
- } else if r == nil {
+
+ case r == nil:
f(l.Key, l.Val, nil)
l = <-oldItems
- } else {
+
+ default:
switch bytes.Compare(l.Key, r.Key) {
case -1: // l < r
f(l.Key, l.Val, nil)
@@ -65,7 +65,6 @@ func gkvCollide(o, n memCollection, f func(k, ov, nv []byte)) {
}
}
}
- wg.Wait()
}
// memStore is a gkvlite.Store which will panic for anything which might

Powered by Google App Engine
This is Rietveld 408576698