Skip to content

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

Merged
merged 7 commits into from
Apr 11, 2018
Merged

Refactor deserialization methods #1038

merged 7 commits into from
Apr 11, 2018

Conversation

rsgowman
Copy link
Member

@rsgowman rsgowman commented Apr 6, 2018

Similar to the refactoring work for the serialization methods.

@rsgowman
Copy link
Member Author

rsgowman commented Apr 6, 2018

NB: It might be easiest to review one commit at at time.

@rsgowman rsgowman requested review from var-const and zxu123 April 6, 2018 18:22
Copy link
Contributor

@zxu123 zxu123 left a 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)
Copy link
Contributor

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)

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope; removed.

@rsgowman rsgowman requested a review from wilhuff April 9, 2018 19:57
Copy link
Contributor

@wilhuff wilhuff left a 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);
Copy link
Contributor

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)};

Copy link
Member Author

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.)

@rsgowman rsgowman merged commit 651e127 into master Apr 11, 2018
@rsgowman rsgowman deleted the rsgowman/refactor_ostream branch April 11, 2018 19:18
minafarid pushed a commit to minafarid/firebase-ios-sdk that referenced this pull request Jun 6, 2018
@firebase firebase locked and limited conversation to collaborators Nov 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants