From 11a44a94b11994a2e6383b2ef2971167e49bec15 Mon Sep 17 00:00:00 2001 From: Andras Banki-Horvath Date: Fri, 25 Jun 2021 17:16:30 +0200 Subject: [PATCH] etcd: remove unnecessary iterator step from cursor Delete The etcd cursor Delete stepped to the next item in the range before Delete to not invalidate the iteation. This is unnecessary and not compatible with bbolt, resulting in an extra fetch too. --- kvdb/etcd/readwrite_cursor.go | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/kvdb/etcd/readwrite_cursor.go b/kvdb/etcd/readwrite_cursor.go index fb408b8f..123f2a5c 100644 --- a/kvdb/etcd/readwrite_cursor.go +++ b/kvdb/etcd/readwrite_cursor.go @@ -116,23 +116,11 @@ func (c *readWriteCursor) Seek(seek []byte) (key, value []byte) { // invalidating the cursor. Returns ErrIncompatibleValue if attempted // when the cursor points to a nested bucket. func (c *readWriteCursor) Delete() error { - // Get the next key after the current one. We could do this - // after deletion too but it's one step more efficient here. - nextKey, err := c.bucket.tx.stm.Next(c.prefix, c.currKey) - if err != nil { - return err - } - if isBucketKey(c.currKey) { c.bucket.DeleteNestedBucket(getKey(c.currKey)) } else { c.bucket.Delete(getKey(c.currKey)) } - if nextKey != nil { - // Set current key to the next one. - c.currKey = nextKey.key - } - return nil }