1
0
Fork 0
mirror of https://github.com/MillironX/XAM.jl.git synced 2024-11-23 10:19:56 +00:00

Preallocate

This commit is contained in:
Ciarán O'Mara 2020-02-02 21:29:20 +11:00
parent 789cccbaff
commit b0069d6f27

View file

@ -97,16 +97,16 @@ function init_bam_reader(input::BGZFStreams.BGZFStream)
samreader = SAM.Reader(IOBuffer(read(input, textlen)))
# reference sequences
refseqnames = String[]
refseqlens = Int[]
n_refs = read(input, Int32)
for _ in 1:n_refs
refseqnames = Vector{String}(undef, n_refs)
refseqlens = Vector{Int}(undef, n_refs)
@inbounds for i in 1:n_refs
namelen = read(input, Int32)
data = read(input, namelen)
seqname = unsafe_string(pointer(data))
seqlen = read(input, Int32)
push!(refseqnames, seqname)
push!(refseqlens, seqlen)
refseqnames[i] = seqname
refseqlens[i] = seqlen
end
voffset = isa(input.io, Base.AbstractPipe) ?