Skip to content

Conversation

@nhz2
Copy link
Member

@nhz2 nhz2 commented May 5, 2024

This PR makes the behavior of stop_on_end=true consistent when wrapping another TranscodingStream with sharedbuf=false or sharedbuf=true.

@nhz2 nhz2 marked this pull request as ready for review May 5, 2024 15:59
@nhz2 nhz2 requested a review from mkitti May 5, 2024 16:15
if stream.state.mode == :read
if stream.stream isa TranscodingStream && !has_sharedbuf(stream) && !iszero(buffersize(inbuf))
# unread data to match behavior if inbuf was shared.
GC.@preserve inbuf unsafe_unread(stream.stream, bufferptr(inbuf), buffersize(inbuf))
Copy link
Member

Choose a reason for hiding this comment

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

Why do we not have a low-method that does the GC.@preserve?

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess the normal unread should be changed to work with any AbstractVector{UInt8}, then I could just unread a view of inbuf.data. Currently, it only supports Union{Vector{UInt8},Base.CodeUnits{UInt8}}

@nhz2 nhz2 merged commit a79c78f into master May 5, 2024
@nhz2 nhz2 deleted the nz/unread-on-stop branch May 5, 2024 17:10
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.

3 participants