1
0
Fork 0
mirror of https://github.com/MillironX/XAM.jl.git synced 2024-12-23 13:28:16 +00:00

Return early

This commit is contained in:
Ciarán O’Mara 2021-07-03 22:45:47 +10:00
parent 8f26bbf4a7
commit 9d2a70531a

View file

@ -52,10 +52,11 @@ function Base.iterate(iter::OverlapIterator)
end
@assert iter.reader.index !== nothing
chunks = Indexes.overlapchunks(iter.reader.index.index, refindex, iter.interval)
if !isempty(chunks)
seek(iter.reader, first(chunks).start)
if isempty(chunks)
return nothing
end
state = OverlapIteratorState(refindex, chunks, 1, Record())
seek(iter.reader, state.chunks[state.chunkid].start)
return iterate(iter, state)
end
@ -65,7 +66,7 @@ function Base.iterate(iter::OverlapIterator, state)
while BGZFStreams.virtualoffset(iter.reader.stream) < chunk.stop
read!(iter.reader, state.record)
c = compare_intervals(state.record, (state.refindex, iter.interval))
if c == 0
if c == 0 # overlapping
return copy(state.record), state
end
if c > 0
@ -78,6 +79,7 @@ function Base.iterate(iter::OverlapIterator, state)
seek(iter.reader, state.chunks[state.chunkid].start)
end
end
# no more overlapping records
return nothing
end