Return early

alnpos-compat
Ciarán O’Mara 3 years ago
parent 8f26bbf4a7
commit 9d2a70531a

@ -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

Loading…
Cancel
Save