Skip to content

Commit 4f2339d

Browse files
committed
add unsafe_transcode
1 parent cecee56 commit 4f2339d

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/transcode.jl

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ end
106106
"""
107107
transcode!(output::Buffer, codec::Codec, input::Buffer)
108108
109-
Transcode `input` by applying `codec` and storing the results in `output`.
110-
Note that this method does not initialize or finalize `codec`. This is
111-
efficient when you transcode a number of pieces of data, but you need to call
112-
[`TranscodingStreams.initialize`](@ref) and
109+
Transcode `input` by applying `codec` and storing the results in `output`
110+
with validation of input and output. Note that this method does not initialize
111+
or finalize `codec`. This is efficient when you transcode a number of
112+
pieces of data, but you need to call [`TranscodingStreams.initialize`](@ref) and
113113
[`TranscodingStreams.finalize`](@ref) explicitly.
114114
"""
115115
function transcode!(
@@ -118,6 +118,23 @@ function transcode!(
118118
input::Buffer,
119119
)
120120
@assert !Base.mightalias(input.data, output.data) "input and outbut buffers must be independent"
121+
unsafe_transcode!(output, coded, input)
122+
end
123+
124+
"""
125+
unsafe_transcode!(output::Buffer, codec::Codec, input::Buffer)
126+
127+
Transcode `input` by applying `codec` and storing the results in `output`
128+
without validating input or output. Note that this method does not initialize
129+
or finalize `codec`. This is efficient when you transcode a number of
130+
pieces of data, but you need to call [`TranscodingStreams.initialize`](@ref) and
131+
[`TranscodingStreams.finalize`](@ref) explicitly.
132+
"""
133+
function unsafe_transcode!(
134+
output::Buffer,
135+
codec::Codec,
136+
input::Buffer,
137+
)
121138
error = Error()
122139
code = startproc(codec, :write, error)
123140
if code === :error

0 commit comments

Comments
 (0)