mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-12-08 16:50:27 +00:00
Optimize memory allocation of the apat algorithms
Former-commit-id: 5010c5a666b322715b3b81c1078d325e1f647ede
This commit is contained in:
@@ -20,7 +20,9 @@ func RecycleSlice(s *[]byte) {
|
||||
if cap(*s) == 0 {
|
||||
log.Panicln("trying to store a NIL slice in the pool", s == nil, *s == nil, cap(*s))
|
||||
}
|
||||
_BioSequenceByteSlicePool.Put(s)
|
||||
if cap(*s) <= 1024 {
|
||||
_BioSequenceByteSlicePool.Put(s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +30,10 @@ func RecycleSlice(s *[]byte) {
|
||||
//
|
||||
// the slice can be prefilled with the provided values
|
||||
func GetSlice(capacity int) []byte {
|
||||
p := _BioSequenceByteSlicePool.Get().(*[]byte)
|
||||
p := (*[]byte)(nil)
|
||||
if capacity <= 1024 {
|
||||
p = _BioSequenceByteSlicePool.Get().(*[]byte)
|
||||
}
|
||||
|
||||
if p == nil || *p == nil || cap(*p) < capacity {
|
||||
s := make([]byte, 0, capacity)
|
||||
|
||||
Reference in New Issue
Block a user