Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert output of readbytes! to Int #141

Merged
merged 1 commit into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/create.jl
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ function write_data(
throw(ArgumentError("cannot write negative data: $size"))
w, t = 0, round_up(size)
while size > 0
b = min(size, length(buf))
n = readbytes!(data, buf, b)::Integer
b = Int(min(size, length(buf)))::Int
n = Int(readbytes!(data, buf, b))::Int
n < b && eof(data) && throw(EOFError())
w += write(tar, view(buf, 1:n))
size -= n
Expand Down
10 changes: 5 additions & 5 deletions src/extract.jl
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ function git_file_hash(
# where you write data to an IO object and it maintains a hash
padded_size = round_up(size)
while padded_size > 0
max_read_len = Int(min(padded_size, length(buf)))
read_len = readbytes!(tar, buf, max_read_len)
max_read_len = Int(min(padded_size, length(buf)))::Int
read_len = Int(readbytes!(tar, buf, max_read_len))::Int
Comment on lines +299 to +300
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you actually need the annotations of ::Int now? I would think that actually doing Int() would be enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought so, too, and just used Int(...). However, I still got the invalidations with that 😕

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@staticfloat Looks like we can't do anything better than this right now.

read_len < max_read_len && eof(tar) && throw(EOFError())
nonpadded_view = view(buf, 1:Int(min(read_len, size)))
SHA.update!(ctx, nonpadded_view)
Expand Down Expand Up @@ -576,7 +576,7 @@ function read_standard_header(
# zero block indicates end of tarball
if all(iszero, data)
while !eof(io)
r = readbytes!(io, buf)::Integer
r = Int(readbytes!(io, buf))::Int
write(tee, view(buf, 1:r))
end
return nothing
Expand Down Expand Up @@ -700,8 +700,8 @@ function read_data(
)::Nothing
padded_size = round_up(size)
while padded_size > 0
max_read_len = Int(min(padded_size, length(buf)))
read_len = readbytes!(tar, buf, max_read_len)::Integer
max_read_len = Int(min(padded_size, length(buf)))::Int
read_len = Int(readbytes!(tar, buf, max_read_len))::Int
write(tee, view(buf, 1:read_len))
read_len < max_read_len && eof(tar) && throw(EOFError())
size -= write(file, view(buf, 1:Int(min(read_len, size))))
Expand Down