Skip to content

Commit 45769c5

Browse files
committed
pot: fix nil bin
1 parent 53be4c9 commit 45769c5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pot/pot.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ func (t *Pot) Merge(t1 *Pot) (c int) {
375375
return c
376376
}
377377

378-
// Union(t0, t1) return the union of t0 and t1
378+
// Union returns the union of t0 and t1
379379
// it only readlocks the Pot-s to read their pots and
380380
// calculates the union using the applicative union
381381
// the second return value is the number of common elements
@@ -422,15 +422,15 @@ func union(t0, t1 *pot) (*pot, int) {
422422

423423
for {
424424

425-
if !a0 && i0 < l0 && bins0[i0].po <= po {
425+
if !a0 && i0 < l0 && bins0[i0] != nil && bins0[i0].po <= po {
426426
n0 = bins0[i0]
427427
p0 = n0.po
428428
a0 = p0 == po
429429
} else {
430430
a0 = true
431431
}
432432

433-
if !a1 && i1 < l1 && bins1[i1].po <= po {
433+
if !a1 && i1 < l1 && bins1[i1] != nil && bins1[i1].po <= po {
434434
n1 = bins1[i1]
435435
p1 = n1.po
436436
a1 = p1 == po
@@ -535,6 +535,9 @@ func (t *Pot) Each(f func(PotVal, int) bool) bool {
535535
func (t *pot) each(f func(PotVal, int) bool) bool {
536536
var next bool
537537
for _, n := range t.bins {
538+
if n == nil {
539+
return true
540+
}
538541
next = n.each(f)
539542
if !next {
540543
return false

0 commit comments

Comments
 (0)