Skip to content

Commit

Permalink
Merge pull request #20 from tkoolen/iostream-encode
Browse files Browse the repository at this point in the history
Use Base.IOStream instead of BufferedStreams.BufferedOutputStream by default
  • Loading branch information
rdeits authored Nov 1, 2017
2 parents 5bd0e6d + da17e76 commit ace8e39
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lcmtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ function encodefield(io::IO, A::AbstractVector)
end

# Sugar
encode(data::Vector{UInt8}, x::LCMType) = encode(BufferedOutputStream(data), x)
encode(x::LCMType) = (stream = BufferedOutputStream(); encode(stream, x); flush(stream); take!(stream))
encode(data::Vector{UInt8}, x::LCMType) = encode(IOBuffer(data, false, true), x)
encode(x::LCMType) = (stream = IOBuffer(false, true); encode(stream, x); flush(stream); take!(stream))

decode!(x::LCMType, data::Vector{UInt8}) = decode!(x, BufferedInputStream(data))
decode(data::Vector{UInt8}, ::Type{T}) where {T<:LCMType} = decode!(T(), data)

0 comments on commit ace8e39

Please sign in to comment.