-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Refactor deserialization methods #1038
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
Conversation
Not complete just yet; see TODOs for details.
NB: It might be easiest to review one commit at at time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
*/ | ||
uint64_t ReadVarint(); | ||
|
||
// TODO(rsgowman): convert to a pb_istream_t (i.e. not a pointer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment still relevant? (stream_
is not a pointer)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope; removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -166,22 +249,38 @@ Writer Writer::Wrap(std::vector<uint8_t>* out_bytes) { | |||
return Writer(raw_stream); | |||
} | |||
|
|||
Reader Reader::Wrap(const uint8_t* bytes, size_t length) { | |||
pb_istream_t raw_stream = pb_istream_from_buffer(bytes, length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few things:
- clang-tidy will complain about "repeating the return type"
- please use brace initialization if possible
Taken together: could this be
return {pb_istream_from_buffer(bytes, length)};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, though as:
return Reader{pb_istream_from_buffer(bytes, length)};
(since ctor is explicit and lint otherwise complains.)
Similar to the refactoring work for the serialization methods.