github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/pkg/storage/stores/shipper/index/compactor/pool.go (about) 1 package compactor 2 3 import ( 4 "sync" 5 ) 6 7 type componentRef struct { 8 components [][]byte 9 } 10 11 var ( 12 componentPools = sync.Pool{ 13 New: func() interface{} { 14 return &componentRef{ 15 components: make([][]byte, 0, 5), 16 } 17 }, 18 } 19 ) 20 21 func getComponents() *componentRef { 22 ref := componentPools.Get().(*componentRef) 23 ref.components = ref.components[:0] 24 return ref 25 } 26 27 func putComponents(ref *componentRef) { 28 componentPools.Put(ref) 29 }