mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-12-08 16:50:27 +00:00
Reducing memory allocation events
Former-commit-id: c94e79ba116464504580fc397270ead154063971
This commit is contained in:
@@ -81,12 +81,16 @@ func FormatFastaBatch(batch obiiter.BioSequenceBatch, formater FormatHeader, ski
|
||||
var bs bytes.Buffer
|
||||
|
||||
// Iterate over each sequence in the batch
|
||||
for _, seq := range batch.Slice() {
|
||||
for i, seq := range batch.Slice() {
|
||||
// Check if the sequence is empty
|
||||
if seq.Len() > 0 {
|
||||
// Format the sequence using the provided formater function
|
||||
formattedSeq := FormatFasta(seq, formater)
|
||||
|
||||
if i == 0 {
|
||||
bs.Grow(len(formattedSeq) * len(batch.Slice()) * 5 / 4)
|
||||
}
|
||||
|
||||
// Append the formatted sequence to the buffer
|
||||
bs.WriteString(formattedSeq)
|
||||
bs.WriteByte('\n')
|
||||
|
||||
Reference in New Issue
Block a user