Clean up after #636

freelist.lenall duplicated freelist.count.
freelist.copyall and mergepgids docs had typos.
master
Josh Bleecher Snyder 2016-12-22 17:05:52 -08:00
parent f0cf3bfd5b
commit 1858583b3b
3 changed files with 5 additions and 14 deletions

View File

@ -46,17 +46,8 @@ func (f *freelist) pending_count() int {
return count
}
// lenall returns the combined number of all free ids and all pending ids.
func (f *freelist) lenall() int {
n := len(f.ids)
for _, list := range f.pending {
n += len(list)
}
return n
}
// all copies into dst a list of all free ids and all pending ids in one sorted list.
// f.lenall returns the minimum length required for dst.
// copyall copies into dst a list of all free ids and all pending ids in one sorted list.
// f.count returns the minimum length required for dst.
func (f *freelist) copyall(dst []pgid) {
m := make(pgids, 0, len(f.pending)) // len(f.pending) undercounts, but it is a start
for _, list := range f.pending {
@ -200,7 +191,7 @@ func (f *freelist) write(p *page) error {
// The page.count can only hold up to 64k elements so if we overflow that
// number then we handle it by putting the size in the first element.
lenids := f.lenall()
lenids := f.count()
if lenids == 0 {
p.count = uint16(lenids)
} else if lenids < 0xFFFF {

View File

@ -154,7 +154,7 @@ func (a pgids) merge(b pgids) pgids {
return merged
}
// merge copies the sorted union of a and b into dst.
// mergepgids copies the sorted union of a and b into dst.
// If dst is too small, it panics.
func mergepgids(dst, a, b pgids) {
if len(dst) < len(a)+len(b) {

2
tx.go
View File

@ -381,7 +381,7 @@ func (tx *Tx) Check() <-chan error {
func (tx *Tx) check(ch chan error) {
// Check if any pages are double freed.
freed := make(map[pgid]bool)
all := make([]pgid, tx.db.freelist.lenall())
all := make([]pgid, tx.db.freelist.count())
tx.db.freelist.copyall(all)
for _, id := range all {
if freed[id] {