Skip to content

Commit

Permalink
Annotate const fields as const
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobnissen committed Oct 17, 2024
1 parent 6d0e5ae commit 2e18425
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/biosequence/printing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ Base.summary(seq::BioSequence{<:AminoAcidAlphabet}) = string(length(seq), "aa ",
# Buffer type. Not exposed to user, so code should be kept simple and performant.
# B is true if it is buffered and false if it is not
mutable struct SimpleBuffer{B, T} <: IO
const io::T
const arr::Vector{UInt8}
len::UInt
arr::Vector{UInt8}
io::T
end

SimpleBuffer(io::IO) = SimpleBuffer{true, typeof(io)}(0, Vector{UInt8}(undef, 1024), io)
SimpleBuffer(io::IO, len) = SimpleBuffer{false, typeof(io)}(0, Vector{UInt8}(undef, len), io)
SimpleBuffer(io::IO) = SimpleBuffer{true, typeof(io)}(io, Vector{UInt8}(undef, 1024), 0)
SimpleBuffer(io::IO, len) = SimpleBuffer{false, typeof(io)}(io, Vector{UInt8}(undef, len), 0)

function Base.write(sb::SimpleBuffer{true}, byte::UInt8)
sb.len 1024 && flush(sb)
Expand Down
2 changes: 1 addition & 1 deletion src/longsequences/longsequence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ The same applies with `LongSequence{RNAAlphabet{4}}`, simply replace the alphabe
parameter with `RNAAlphabet{2}` in order to benefit.
"""
mutable struct LongSequence{A <: Alphabet} <: BioSequence{A}
data::Vector{UInt64} # encoded character sequence data
const data::Vector{UInt64} # encoded character sequence data
len::UInt

function LongSequence{A}(data::Vector{UInt64}, len::UInt) where {A <: Alphabet}
Expand Down
8 changes: 4 additions & 4 deletions src/search/re.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ import BioSequences
# -----------

mutable struct SyntaxTree
head::Symbol
args::Vector{Any}
const head::Symbol
const args::Vector{Any}

function SyntaxTree(head, args)
@assert head (
Expand Down Expand Up @@ -805,11 +805,11 @@ end

# simple stack
mutable struct Stack{T}
const data::Vector{T}
top::Int
data::Vector{T}

function Stack{T}(sz::Int=0) where T
return new{T}(0, Vector{T}(undef, sz))
return new{T}(Vector{T}(undef, sz), 0)
end
end

Expand Down

0 comments on commit 2e18425

Please sign in to comment.