aboutsummaryrefslogtreecommitdiff
path: root/cursor.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2015-01-30 14:15:49 -0500
committerBen Johnson <benbjohnson@yahoo.com>2015-01-30 14:15:49 -0500
commitb4d00c394a1feb8b2c6404e01be891e4a997ef35 (patch)
tree808df0d71e9c94045d2e8b30be7b1d5256a34c3f /cursor.go
parentMerge pull request #292 from benbjohnson/fix-size (diff)
downloaddedo-b4d00c394a1feb8b2c6404e01be891e4a997ef35.tar.gz
dedo-b4d00c394a1feb8b2c6404e01be891e4a997ef35.tar.xz
Expand assertion statements.
This commit expands calls to _assert() that use variadic arguments. These calls require conversion to interface{} so there was a large number of calls to Go's internal convT2E() function. In some profiling this was taking over 20% of total runtime. I don't remember seeing this before Go 1.4 so perhaps something has changed.
Diffstat (limited to 'cursor.go')
-rw-r--r--cursor.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/cursor.go b/cursor.go
index 3bfc2f1..0d8ed16 100644
--- a/cursor.go
+++ b/cursor.go
@@ -2,6 +2,7 @@ package bolt
import (
"bytes"
+ "fmt"
"sort"
)
@@ -228,8 +229,8 @@ func (c *Cursor) next() (key []byte, value []byte, flags uint32) {
// search recursively performs a binary search against a given page/node until it finds a given key.
func (c *Cursor) search(key []byte, pgid pgid) {
p, n := c.bucket.pageNode(pgid)
- if p != nil {
- _assert((p.flags&(branchPageFlag|leafPageFlag)) != 0, "invalid page type: %d: %x", p.id, p.flags)
+ if p != nil && (p.flags&(branchPageFlag|leafPageFlag)) == 0 {
+ panic(fmt.Sprintf("invalid page type: %d: %x", p.id, p.flags))
}
e := elemRef{page: p, node: n}
c.stack = append(c.stack, e)