diff --git a/freelist.go b/freelist.go index df544cea..88df45ca 100644 --- a/freelist.go +++ b/freelist.go @@ -174,7 +174,14 @@ func (f *freelist) read(p *page) { copy(f.ids, ids) // Make sure they're sorted. - sort.Sort(pgids(f.ids)) + if len(f.ids) > 0 { + for i, v := range f.ids[:len(f.ids)-1] { + if f.ids[i+1] < v { + sort.Sort(pgids(f.ids)) + break + } + } + } // Rebuild the page cache. f.reindex()