From 0bf4edcf324caf3c514463e7b3899a9bdf1385de Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 6 Aug 2019 17:35:28 +0000 Subject: [PATCH] Avoid unnecessary conversions No need to convert here, they are already of the right type. --- cmd/bbolt/main.go | 2 +- cursor.go | 2 +- freelist_hmap.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/bbolt/main.go b/cmd/bbolt/main.go index 1a54804..91a13bc 100644 --- a/cmd/bbolt/main.go +++ b/cmd/bbolt/main.go @@ -774,7 +774,7 @@ func (cmd *PageCommand) PrintFreelist(w io.Writer, buf []byte) error { // Print each page in the freelist. ids := (*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)) - for i := int(idx); i < count; i++ { + for i := idx; i < count; i++ { fmt.Fprintf(w, "%d\n", ids[i]) } fmt.Fprintf(w, "\n") diff --git a/cursor.go b/cursor.go index 3000ace..98aeb44 100644 --- a/cursor.go +++ b/cursor.go @@ -366,7 +366,7 @@ func (c *Cursor) node() *node { } for _, ref := range c.stack[:len(c.stack)-1] { _assert(!n.isLeaf, "expected branch node") - n = n.childAt(int(ref.index)) + n = n.childAt(ref.index) } _assert(n.isLeaf, "expected leaf node") return n diff --git a/freelist_hmap.go b/freelist_hmap.go index 6a03a6c..02ef2be 100644 --- a/freelist_hmap.go +++ b/freelist_hmap.go @@ -27,7 +27,7 @@ func (f *freelist) hashmapAllocate(txid txid, n int) pgid { f.allocs[pid] = txid for i := pgid(0); i < pgid(n); i++ { - delete(f.cache, pid+pgid(i)) + delete(f.cache, pid+i) } return pid }