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

Allow unread of AbstractVector{UInt8} #212

Merged
merged 3 commits into from
May 5, 2024
Merged

Conversation

nhz2
Copy link
Member

@nhz2 nhz2 commented May 5, 2024

Fixes #210

@nhz2 nhz2 marked this pull request as ready for review May 5, 2024 18:02
@nhz2 nhz2 requested a review from mkitti May 5, 2024 18:12
@nhz2 nhz2 marked this pull request as draft May 5, 2024 18:21
Copy link
Member

@mkitti mkitti left a comment

Choose a reason for hiding this comment

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

We may need to preserve the public API or deprecate that particular method.

You could also consider Base.require_one_based_indexing if there is any question about the applicability to AbstractVector.

src/buffer.jl Show resolved Hide resolved
@@ -213,7 +215,9 @@ function insertdata!(buf::Buffer, data::Ptr{UInt8}, nbytes::Integer)
end
datasize = buf.marginpos - datapos
copyto!(buf.data, datapos + nbytes, buf.data, datapos, datasize)
GC.@preserve buf unsafe_copyto!(bufferptr(buf), data, nbytes)
for i in 0:nbytes-1
Copy link
Member

Choose a reason for hiding this comment

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

Could you use copyto!?

Copy link
Member Author

Choose a reason for hiding this comment

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

copyto! isn't defined for TranscodingStreams.Memory, but it does have getindex

Copy link
Member Author

Choose a reason for hiding this comment

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

Also copyto! seems like it has special cases for handling aliasing. JuliaLang/julia#50900
This isn't needed here.

@nhz2 nhz2 marked this pull request as ready for review May 5, 2024 19:29
@nhz2 nhz2 merged commit 2d2d420 into master May 5, 2024
26 checks passed
@nhz2 nhz2 deleted the nz/unread-abstractvector branch May 5, 2024 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow unread of AbstractVector{UInt8}
2 participants