Skip to content

Conversation

@nhz2
Copy link
Member

@nhz2 nhz2 commented May 4, 2024

On master

julia> using TranscodingStreams

julia> stream = NoopStream(IOBuffer("foobar"));

julia> mark(stream)
0

julia> read(stream, String)
"foobar"

julia> TranscodingStreams.unread(stream, b"bar")

julia> reset(stream)
-3

julia> read(stream, String)
"foobarbar"

With this PR:

julia> using TranscodingStreams

julia> stream = NoopStream(IOBuffer("foobar"));

julia> mark(stream)
0

julia> read(stream, String)
"foobar"

julia> TranscodingStreams.unread(stream, b"bar")

julia> reset(stream)
0

julia> read(stream, String)
"foobar"

@nhz2 nhz2 force-pushed the nz/unread-and-mark branch from ed2d0b8 to c61e12e Compare May 4, 2024 19:32
min(buf.markpos, buf.bufferpos)
end
datasize = buf.marginpos - datapos
copyto!(buf.data, datapos + nbytes, buf.data, datapos, datasize)
Copy link
Member Author

Choose a reason for hiding this comment

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

These changes ensure the marked data and buffered data stay together.

@nhz2 nhz2 marked this pull request as ready for review May 4, 2024 20:07
@nhz2 nhz2 requested review from jakobnissen and mkitti May 4, 2024 20:14
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.

Looks food. I'm not sure if we should be using @Assert so much

@nhz2 nhz2 merged commit 8fdabed into master May 4, 2024
@nhz2 nhz2 deleted the nz/unread-and-mark branch May 4, 2024 22:13
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