mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Optimize memory allocation of the apat algorithms
Former-commit-id: 5010c5a666b322715b3b81c1078d325e1f647ede
This commit is contained in:
@ -34,14 +34,22 @@ func MakeBioSequenceSlice(size ...int) BioSequenceSlice {
|
||||
return *NewBioSequenceSlice(size...)
|
||||
}
|
||||
|
||||
func (s *BioSequenceSlice) Recycle() {
|
||||
func (s *BioSequenceSlice) Recycle(including_seq bool) {
|
||||
if s == nil {
|
||||
log.Panicln("Trying too recycle a nil pointer")
|
||||
}
|
||||
|
||||
// Code added to potentially limit memory leaks
|
||||
for i := range *s {
|
||||
(*s)[i] = nil
|
||||
if including_seq {
|
||||
for i := range *s {
|
||||
(*s)[i] .Recycle()
|
||||
(*s)[i] = nil
|
||||
}
|
||||
|
||||
} else {
|
||||
for i := range *s {
|
||||
(*s)[i] = nil
|
||||
}
|
||||
}
|
||||
|
||||
*s = (*s)[:0]
|
||||
|
Reference in New Issue
Block a user