From 3267f59ee3e5899cfc0d3ac1b92fb2b0dd2be6f7 Mon Sep 17 00:00:00 2001 From: Ujin Date: Sun, 3 Jul 2022 06:18:21 +0300 Subject: [PATCH] fix array allocation --- src/WebSockets.jl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/WebSockets.jl b/src/WebSockets.jl index c830d6100..c5b180ed1 100644 --- a/src/WebSockets.jl +++ b/src/WebSockets.jl @@ -93,21 +93,23 @@ end function compress(data::T) where T <: AbstractVector{UInt8} compressed = transcode(DeflateCompressor, data) - return vcat(compressed, 0x00) + push!(compressed, 0x00) + return compressed end function compress(data::String) compressed = transcode(DeflateCompressor, data) - return String(vcat(compressed, 0x00)) + push!(compressed, 0x00) + return String(compressed) end function decompress(data::T) where T <: AbstractVector{UInt8} - decompressed = transcode(DeflateDecompressor, vcat(data, [0x00, 0x00, 0xff, 0xff, 0x03, 0x00])) + decompressed = transcode(DeflateDecompressor, append!(data, [0x00, 0x00, 0xff, 0xff, 0x03, 0x00])) return decompressed end function decompress(data::String) - decompressed = transcode(DeflateDecompressor, vcat(Vector{UInt8}(data), [0x00, 0x00, 0xff, 0xff, 0x03, 0x00])) + decompressed = transcode(DeflateDecompressor, append!(Vector{UInt8}(data), [0x00, 0x00, 0xff, 0xff, 0x03, 0x00])) return String(decompressed) end