Skip to content

Commit

Permalink
[REFACTOR] Improve SSL parser, reduce memory allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
captchanjack committed Jan 30, 2022
1 parent 9881a08 commit 226ff5d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Jedis"
uuid = "b89ccfe0-2c5f-46f6-b89b-da3e1c2e286f"
authors = ["Jack Chan <[email protected]>"]
version = "0.2.9"
version = "0.2.10"

[deps]
MbedTLS = "739be429-bea8-5141-9913-cc70e7f3736d"
Expand Down
7 changes: 5 additions & 2 deletions src/protocol.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function parse_bulk_string(io, x)
return nothing
end

x = parse(Int, x) + 2
x = parse(Int64, x) + 2
buffer = Vector{UInt8}(undef, x)
readbytes!(io, buffer, x)
return String(buffer[1:end-2])
Expand Down Expand Up @@ -109,5 +109,8 @@ Copies all available decrypted bytes from an MbedTLS.SSLContext into an IOBuffer
"""
function recv(io::MbedTLS.SSLContext)
MbedTLS.wait_for_decrypted_data(io)
return recv(IOBuffer(readavailable(io)))
nb = bytesavailable(io)
buffer = IOBuffer(Vector{UInt8}(undef, nb))
readbytes!(io, buffer.data, nb)
return recv(buffer)
end

2 comments on commit 226ff5d

@captchanjack
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/53464

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.10 -m "<description of version>" 226ff5d09c807c170ed31e02b8cfae2541e5bc87
git push origin v0.2.10

Please sign in to comment.