mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-12-08 16:50:27 +00:00
Reduce memory allocation events
Former-commit-id: fbdb2afc857b02adc2593e2278d3bd838e99b0b2
This commit is contained in:
@@ -12,6 +12,7 @@ package obiseq
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"slices"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
@@ -418,12 +419,15 @@ func (s *BioSequence) SetFeatures(feature []byte) {
|
||||
s.feature = feature
|
||||
}
|
||||
|
||||
// Setting the sequence of the BioSequence.
|
||||
// SetSequence sets the sequence of the BioSequence.
|
||||
//
|
||||
// Parameters:
|
||||
// - sequence: a byte slice representing the sequence to be set.
|
||||
func (s *BioSequence) SetSequence(sequence []byte) {
|
||||
if s.sequence != nil {
|
||||
RecycleSlice(&s.sequence)
|
||||
}
|
||||
s.sequence = CopySlice(obiutils.InPlaceToLower(sequence))
|
||||
s.sequence = obiutils.InPlaceToLower(CopySlice(sequence))
|
||||
}
|
||||
|
||||
// Setting the qualities of the BioSequence.
|
||||
@@ -507,3 +511,15 @@ func (s *BioSequence) Composition() map[byte]int {
|
||||
|
||||
return counts
|
||||
}
|
||||
|
||||
func (s *BioSequence) Grow(length int) {
|
||||
if s.sequence == nil {
|
||||
s.sequence = GetSlice(length)
|
||||
} else {
|
||||
s.sequence = slices.Grow(s.sequence, length)
|
||||
}
|
||||
|
||||
if s.qualities != nil {
|
||||
s.qualities = slices.Grow(s.qualities, length)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user