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

Expose resetting the position in CodedOutputStream (C#) #7676

Closed
MaximGurschi opened this issue Jul 2, 2020 · 3 comments
Closed

Expose resetting the position in CodedOutputStream (C#) #7676

MaximGurschi opened this issue Jul 2, 2020 · 3 comments

Comments

@MaximGurschi
Copy link

MaximGurschi commented Jul 2, 2020

Hi,

What do you think of a small update to the COS, to support resetting the position, if the data is written to a flat array directly?
The use case is the ability to reuse the same COS with a preallocated buffer.
This should help with some GC concerns around COS.

The effect of resetting the position is achievable by using the Stream ctors on COS, but that means that every byte must go through an intermediary stream before landing in the preallocated buffer.

@acozzette
Copy link
Member

Why not just call msg.SerializeToArray(...) and not use a CodedOutputStream at all?

@MaximGurschi MaximGurschi changed the title Expose resetting the position in CodedOutputStream Expose resetting the position in CodedOutputStream (C#) Jul 6, 2020
@MaximGurschi
Copy link
Author

@acozzette That API is not available in C#? I should have specified the language in the post.

@MaximGurschi
Copy link
Author

I think this will be achievable once
#7576

, is released. Closing for now.

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

No branches or pull requests

2 participants