Skip to content

Commit

Permalink
add unsafe_transcode
Browse files Browse the repository at this point in the history
  • Loading branch information
baumgold committed Apr 18, 2023
1 parent cecee56 commit 4f2339d
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/transcode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ end
"""
transcode!(output::Buffer, codec::Codec, input::Buffer)
Transcode `input` by applying `codec` and storing the results in `output`.
Note that this method does not initialize or finalize `codec`. This is
efficient when you transcode a number of pieces of data, but you need to call
[`TranscodingStreams.initialize`](@ref) and
Transcode `input` by applying `codec` and storing the results in `output`
with validation of input and output. Note that this method does not initialize
or finalize `codec`. This is efficient when you transcode a number of
pieces of data, but you need to call [`TranscodingStreams.initialize`](@ref) and
[`TranscodingStreams.finalize`](@ref) explicitly.
"""
function transcode!(
Expand All @@ -118,6 +118,23 @@ function transcode!(
input::Buffer,
)
@assert !Base.mightalias(input.data, output.data) "input and outbut buffers must be independent"
unsafe_transcode!(output, coded, input)
end

"""
unsafe_transcode!(output::Buffer, codec::Codec, input::Buffer)
Transcode `input` by applying `codec` and storing the results in `output`
without validating input or output. Note that this method does not initialize
or finalize `codec`. This is efficient when you transcode a number of
pieces of data, but you need to call [`TranscodingStreams.initialize`](@ref) and
[`TranscodingStreams.finalize`](@ref) explicitly.
"""
function unsafe_transcode!(
output::Buffer,
codec::Codec,
input::Buffer,
)
error = Error()
code = startproc(codec, :write, error)
if code === :error
Expand Down

0 comments on commit 4f2339d

Please sign in to comment.