mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Reducing memory allocation events
Former-commit-id: c94e79ba116464504580fc397270ead154063971
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
package obiformats
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"math"
|
||||
"strings"
|
||||
"unsafe"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
@ -85,17 +87,26 @@ func ParseFastSeqJsonHeader(sequence *obiseq.BioSequence) {
|
||||
}
|
||||
}
|
||||
|
||||
func FormatFastSeqJsonHeader(sequence *obiseq.BioSequence) string {
|
||||
func WriteFastSeqJsonHeader(buffer *bytes.Buffer, sequence *obiseq.BioSequence) {
|
||||
|
||||
annotations := sequence.Annotations()
|
||||
|
||||
if len(annotations) > 0 {
|
||||
text, err := obiutils.JsonMarshal(sequence.Annotations())
|
||||
err := obiutils.JsonMarshalByteBuffer(buffer, sequence.Annotations())
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return string(text)
|
||||
func FormatFastSeqJsonHeader(sequence *obiseq.BioSequence) string {
|
||||
annotations := sequence.Annotations()
|
||||
buffer := bytes.Buffer{}
|
||||
|
||||
if len(annotations) > 0 {
|
||||
obiutils.JsonMarshalByteBuffer(&buffer, sequence.Annotations())
|
||||
return unsafe.String(unsafe.SliceData(buffer.Bytes()), len(buffer.Bytes()))
|
||||
}
|
||||
|
||||
return ""
|
||||
|
Reference in New Issue
Block a user