Skip to content

Commit

Permalink
Use one implementation of memcmp
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobnissen committed Aug 10, 2022
1 parent 020e384 commit e29fdc7
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 11 deletions.
4 changes: 4 additions & 0 deletions src/FASTX.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ function truncate(s::AbstractString, len::Integer)
end
end

function memcmp(p1::Ptr, p2::Ptr, n::Integer)
return ccall(:memcmp, Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t), p1, p2, n)
end

include("fasta/fasta.jl")
include("fastq/fastq.jl")

Expand Down
2 changes: 1 addition & 1 deletion src/fasta/fasta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import TranscodingStreams: TranscodingStreams, TranscodingStream, NoopStream
# Trivial use, I only use it here because it's a dep of Automa anyway.
# Can be removed with no big problems
using ScanByte: memchr, ByteSet
import ..FASTX: identifier, description, sequence, UTF8, seqlen, throw_parser_error, truncate
import ..FASTX: identifier, description, sequence, UTF8, seqlen, throw_parser_error, truncate, memcmp

include("record.jl")
include("readrecord.jl")
Expand Down
4 changes: 0 additions & 4 deletions src/fasta/record.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,6 @@ function Base.show(io::IO, record::Record)
print(io, " sequence: \"", truncate(sequence(record), 40), '"')
end

function memcmp(p1::Ptr, p2::Ptr, n::Integer)
return ccall(:memcmp, Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t), p1, p2, n)
end

# TODO: Base's hash does not hash all elements. Do we have a better implementation?
function Base.hash(record::Record, h::UInt)
# The description length is informative of the record's content
Expand Down
2 changes: 1 addition & 1 deletion src/fastq/fastq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import BioGenerics: BioGenerics
import BioGenerics.Automa: State
import StringViews: StringView
import TranscodingStreams: TranscodingStreams, TranscodingStream, NoopStream
import ..FASTX: identifier, description, sequence, UTF8, seqlen, throw_parser_error, truncate
import ..FASTX: identifier, description, sequence, UTF8, seqlen, throw_parser_error, truncate, memcmp

include("quality.jl")
include("record.jl")
Expand Down
5 changes: 0 additions & 5 deletions src/fastq/record.jl
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,6 @@ function Base.show(io::IO, record::Record)
print(io, " quality: \"", truncate(quality(record), 40), '"')
end

function memcmp(p1::Ptr, p2::Ptr, n::Integer)
return ccall(:memcmp, Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t), p1, p2, n)
end


# Accessor functions
# ------------------

Expand Down

0 comments on commit e29fdc7

Please sign in to comment.