func (f *flt) setHead(h, atoms int64, fi Filer) (err error) { switch { case atoms < 1: panic(atoms) case atoms >= maxFLTRq: b := bufs.GCache.Get(7) defer bufs.GCache.Put(b) if _, err = fi.WriteAt(h2b(b[:], h), 8*13+1); err != nil { return } f[13].head = h return default: lg := mathutil.Log2Uint16(uint16(atoms)) g := f[lg:] for i := range f { if atoms < g[i+1].minSize { b := bufs.GCache.Get(7) defer bufs.GCache.Put(b) if _, err = fi.WriteAt(h2b(b[:], h), 8*int64(i+lg)+1); err != nil { return } g[i].head = h return } } panic("internal error") } }
func (f *flt) head(atoms int64) (h int64) { switch { case atoms < 1: panic(atoms) case atoms >= maxFLTRq: return f[13].head default: lg := mathutil.Log2Uint16(uint16(atoms)) g := f[lg:] for i := range g { if atoms < g[i+1].minSize { return g[i].head } } panic("internal error") } }
func (f *flt) find(rq int) (h int64) { switch { case rq < 1: panic(rq) case rq >= maxFLTRq: h, f[13].head = f[13].head, 0 return default: g := f[mathutil.Log2Uint16(uint16(rq)):] for i := range g { p := &g[i] if rq <= int(p.minSize) { if h = p.head; h != 0 { p.head = 0 return } } } return } }