Skip to content

Commit

Permalink
Mark 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 552aeb0 commit 8199a40
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/fasta/reader.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ AGA
```
"""
mutable struct Reader{S <: TranscodingStream} <: BioGenerics.IO.AbstractReader
stream::S
const stream::S
const record::Record
automa_state::Int
# set to typemin(Int) if reader uses seek, then the linenum is
# irreversibly lost.
encoded_linenum::Int
index::Union{Index, Nothing}
record::Record
copy::Bool

function Reader{T}(io::T, index::Union{Index, Nothing}, copy::Bool) where {T <: TranscodingStream}
record = Record(Vector{UInt8}(undef, 2048), 0, 0, 0)
new{T}(io, 1, 1, index, record, copy)
new{T}(io, record, 1, 1, index, copy)
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/fasta/record.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ true
mutable struct Record
# Data contains the description, then the sequence immediately after
# without newlines, or the initial > symbol, and then any unused trailing bytes
data::Vector{UInt8}
const data::Vector{UInt8}

# These lengths are in bytes, not chars
# Identifier is data[1:identifier_len]
Expand Down
4 changes: 2 additions & 2 deletions src/fasta/writer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ end
```
"""
mutable struct Writer{S <: TranscodingStream} <: BioGenerics.IO.AbstractWriter
output::S
const output::S
# maximum sequence width (no limit when width ≤ 0)
width::Int
const width::Int

function Writer{S}(output::S, width::Int) where {S <: TranscodingStream}
finalizer(new{S}(output, width)) do writer
Expand Down
6 changes: 3 additions & 3 deletions src/fastq/reader.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ Int8[73, 74, 26, 60]
```
"""
mutable struct Reader{S <: TranscodingStream} <: BioGenerics.IO.AbstractReader
stream::S
const stream::S
const record::Record
automa_state::Int
linenum::Int
record::Record
copy::Bool

function Reader{T}(io::T, copy::Bool) where {T <: TranscodingStream}
record = Record(Vector{UInt8}(undef, 2048), 0, 0, 0)
new{T}(io, 1, 1, record, copy)
new{T}(io, record, 1, 1, copy)
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/fastq/record.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ mutable struct Record
# all rest, including newlines and the @ and + symbol, are not stored.
# The second description after + must be identical to first description.
# The quality is not corrected for offset, i.e. it is stored as it in the input file
data::Vector{UInt8}
const data::Vector{UInt8}

# In bytes, not chars
identifier_len::Int32
Expand Down
4 changes: 2 additions & 2 deletions src/fastq/writer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ end
```
"""
mutable struct Writer{S <: TranscodingStream} <: BioGenerics.IO.AbstractWriter
output::S
quality_header::UInt8 # 0x00: No, 0x01: Yes, 0x02: Same as when read
const output::S
const quality_header::UInt8 # 0x00: No, 0x01: Yes, 0x02: Same as when read

function Writer{S}(output::S, quality_header::UInt8) where {S <: TranscodingStream}
finalizer(new{S}(output, quality_header)) do writer
Expand Down

0 comments on commit 8199a40

Please sign in to comment.