From f623ded1e475f8ca4e88251783da97b13901f662 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Fri, 1 Dec 2017 00:36:14 +0000 Subject: [PATCH] Simplify table records loop in iterator --- db/iterator.go | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/db/iterator.go b/db/iterator.go index 9d74bee6..a7b96119 100644 --- a/db/iterator.go +++ b/db/iterator.go @@ -584,29 +584,31 @@ func (i *iterator) processTable(ctx context.Context, key *keys.Table) { return } + // If there are no further records + // fetched from the data layer, then + // return out of this loop iteration. + if x >= len(vals) { return } - for ; x < len(vals); x++ { - - // When we loop around, we will use - // the key of the last retrieved key - // to perform the next range request. - - if x == len(vals)-1 { - beg.Decode(vals[len(vals)-1].Key()) - } + // If there were at least 1 or 2 + // keys-values, then loop over all + // the items and process the records. + for _, val := range vals { if i.checkState(ctx) { - i.submitTask(nil, vals[x], nil) + i.submitTask(nil, val, nil) continue } - - break - } + // When we loop around, we will use + // the key of the last retrieved key + // to perform the next range request. + + beg.Decode(vals[len(vals)-1].Key()) + } }