From 278ef9aa5ed600ca270c817c7ce7be9496528ad2 Mon Sep 17 00:00:00 2001 From: Sokolov Yura aka funny_falcon Date: Mon, 17 Aug 2015 19:17:59 +0300 Subject: [PATCH] sort pgids on file open only if they aren't sorted --- freelist.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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()