-
Notifications
You must be signed in to change notification settings - Fork 37.7k
refactor: serialization simplifications #28203
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
refactor: serialization simplifications #28203
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. |
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.
This looks like a very nice cleanup (and in a widely included and large file).
Have started running a node on this branch.
Initial approach ACK 513f465
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.
very nice, ACK 513f465 🙊
Show signature
Signature:
untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: very nice, ACK 513f4659b0a2ac4e2454ad2425b0fec8d7f64f04 🙊
GEzCyPu57ooJeHDaJ2Nuwgozpyvft2GzjmZzH1LsuCmxm4NLtc+ONqj570HEbSuzwFAnZ/pZOvN9NSTjIWsxDw==
Serialize_impl(os, v, T()); | ||
void Serialize(Stream& os, const prevector<N, T>& v) | ||
{ | ||
if constexpr (std::is_same_v<T, unsigned char>) { |
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.
review note in 10105d9: A simple is_same_v
works, because I presume T
can never include const
in a prevector, similar to how std::vector<const int>
does not exist.
…eMany() Instead of recursively calling `SerializeMany` and peeling off one argument at a time, use a fold expression. This simplifies the code, makes it most likely faster because it reduces the number of function calls, and compiles faster because there are fewer template instantiations.
…izeMany() Instead of recursively calling `UnserializeMany` and peeling off one argument at a time, use a fold expression. This simplifies the code, makes it most likely faster because it reduces the number of function calls, and compiles faster because there are fewer template instantiations.
This gets rid of unnecessarily creating a temporary object T() to call the right function.
This gets rid of unnecessarily creating a temporary object T() to call the right function.
This gets rid of unnecessarily creating a temporary object T() to call the right function.
This gets rid of unnecessarily creating a temporary object T() to call the right function.
513f465
to
f054bd0
Compare
Rebased to f054bd0 to clang-format the changes, and adds back the |
only change is to add a missing Show signatureSignature:
|
ACK f054bd0 |
utACK f054bd0 |
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.
ACK f054bd0
f054bd0 refactor: use "if constexpr" in std::vector's Unserialize() (Martin Leitner-Ankerl) 088caa6 refactor: use "if constexpr" in std::vector's Serialize() (Martin Leitner-Ankerl) 0fafaca refactor: use "if constexpr" in prevector's Unserialize() (Martin Leitner-Ankerl) c8839ec refactor: use "if constexpr" in prevector's Serialize() (Martin Leitner-Ankerl) 1403d18 refactor: use fold expressions instead of recursive calls in UnserializeMany() (Martin Leitner-Ankerl) bd08a00 refactor: use fold expressions instead of recursive calls in SerializeMany() (Martin Leitner-Ankerl) Pull request description: This simplifies the serialization code a bit and should also make it a bit faster. * use fold expressions instead of recursive calls. This simplifies the code, makes it most likely faster because it reduces the number of function calls, and compiles faster because there are fewer template instantiations. * use `if constexpr` instead of unnecessarily creating a temporary object only to call the right overload. This is used for `std::vector` and `prevector` serialization. ACKs for top commit: MarcoFalke: only change is to add a missing `&`. lgtm, re-ACK f054bd0 📦 jonatack: ACK f054bd0 sipa: utACK f054bd0 john-moffett: ACK f054bd0 Tree-SHA512: 0417bf2d6be486c581732297945449211fc3481bac82964e27628b38ef55a47dfa58d730148aeaf1b19fa8eb1076489cc646ceebb178162a9afa59034601501d
This simplifies the serialization code a bit and should also make it a bit faster.
use fold expressions instead of recursive calls. This simplifies the code, makes it most likely faster because it reduces the number of function calls, and compiles faster because there are fewer template instantiations.
use
if constexpr
instead of unnecessarily creating a temporary object only to call the right overload. This is used forstd::vector
andprevector
serialization.