Skip to content

Commit

Permalink
Make more methods take AbstractUnitRange over UnitRange
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobnissen committed Oct 31, 2021
1 parent 812c0e0 commit 65fde1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/longsequences/constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,15 @@ end

function LongSequence{A}(
src::Union{AbstractString,AbstractVector{UInt8}},
part::UnitRange{<:Integer}=1:length(src)
part::AbstractUnitRange{<:Integer}=1:length(src)
) where {A<:Alphabet}
len = length(part)
seq = LongSequence{A}(undef, len)
return copyto!(seq, 1, src, first(part), len)
end


# create a subsequence
function LongSequence(other::LongSequence, part::UnitRange{<:Integer})
function LongSequence(other::LongSequence, part::AbstractUnitRange{<:Integer})
checkbounds(other, part)
subseq = typeof(other)(undef, length(part))
copyto!(subseq, 1, other, first(part), length(part))
Expand Down
6 changes: 3 additions & 3 deletions src/longsequences/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ end
end

# More efficient due to copyto!
function Base.getindex(seq::LongSequence, part::UnitRange{<:Integer})
function Base.getindex(seq::LongSequence, part::AbstractUnitRange{<:Integer})
@boundscheck checkbounds(seq, part)
newseq = typeof(seq)(undef, length(part))
return copyto!(newseq, 1, seq, first(part), length(part))
Expand All @@ -37,7 +37,7 @@ end
function Base.setindex!(
seq::SeqOrView{A},
other::SeqOrView{A},
locs::UnitRange{<:Integer}
locs::AbstractUnitRange{<:Integer}
) where {A <: Alphabet}
@boundscheck checkbounds(seq, locs)
@boundscheck if length(other) != length(locs)
Expand All @@ -48,7 +48,7 @@ end

@inline function encoded_setindex!(
seq::SeqOrView{A},
bin::Unsigned,
bin::Unsigned,
i::Integer
) where {A <: Alphabet}
return encoded_setindex!(seq, bin, bitindex(seq, i))
Expand Down

0 comments on commit 65fde1c

Please sign in to comment.