diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2015-01-30 14:15:49 -0500 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2015-01-30 14:15:49 -0500 |
commit | b4d00c394a1feb8b2c6404e01be891e4a997ef35 (patch) | |
tree | 808df0d71e9c94045d2e8b30be7b1d5256a34c3f /freelist.go | |
parent | Merge pull request #292 from benbjohnson/fix-size (diff) | |
download | dedo-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 'freelist.go')
-rw-r--r-- | freelist.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/freelist.go b/freelist.go index 150e3e6..1346e82 100644 --- a/freelist.go +++ b/freelist.go @@ -1,6 +1,7 @@ package bolt import ( + "fmt" "sort" "unsafe" ) @@ -67,7 +68,9 @@ func (f *freelist) allocate(n int) pgid { var initial, previd pgid for i, id := range f.ids { - _assert(id > 1, "invalid page allocation: %d", id) + if id <= 1 { + panic(fmt.Sprintf("invalid page allocation: %d", id)) + } // Reset initial page if this is not contiguous. if previd == 0 || id-previd != 1 { @@ -103,13 +106,17 @@ func (f *freelist) allocate(n int) pgid { // free releases a page and its overflow for a given transaction id. // If the page is already free then a panic will occur. func (f *freelist) free(txid txid, p *page) { - _assert(p.id > 1, "cannot free page 0 or 1: %d", p.id) + if p.id <= 1 { + panic(fmt.Sprintf("cannot free page 0 or 1: %d", p.id)) + } // Free page and all its overflow pages. var ids = f.pending[txid] for id := p.id; id <= p.id+pgid(p.overflow); id++ { // Verify that page is not already free. - _assert(!f.cache[id], "page %d already freed", id) + if f.cache[id] { + panic(fmt.Sprintf("page %d already freed", id)) + } // Add to the freelist and cache. ids = append(ids, id) |