-
Notifications
You must be signed in to change notification settings - Fork 20
Improve decode performance #53
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,11 +81,11 @@ namespace pp { | |
| con.reserve(len); | ||
| } | ||
|
|
||
| const auto origin_b = b; | ||
| decode_value<typename C::value_type> decode_v; | ||
| while(begin_diff(b, origin_b) < len) { | ||
| while(len) { | ||
| if (Mode::get_value_from_result(C::template decode<Mode>(b), decode_v)) { | ||
| std::tie(*std::inserter(con, con.end()), b) = std::move(decode_v); | ||
| --len; | ||
| } else { | ||
| return {}; | ||
| } | ||
|
|
@@ -122,8 +122,10 @@ namespace pp { | |
| uint<8> n = 0; | ||
| std::tie(n, b) = decode_len; | ||
|
|
||
| if (!Mode::check_bytes_span(b, n)) { | ||
| return {}; | ||
| if constexpr (Mode::need_checks) { | ||
| if (!Mode::check_bytes_span(b, n)) { | ||
| return {}; | ||
| } | ||
| } | ||
|
Comment on lines
+125
to
129
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
And it should be quite easy for compilers to eliminate.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It can eliminate or can not. It depends on compiler, version, mode etc. The code above performs that removal independently from compiler, especially it removes the empty call in debug mode. There can be a lot of them.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm I think another way is to put Since I'm a compiler engineer I can guarantee that every C++ compiler can do this (MSVC/Clang/GCC), because it's quite trivial. |
||
|
|
||
| return Mode::template make_result<decode_skip_result<Mode>>(b.subspan(n)); | ||
|
|
||
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.
Hmm in every iteration, we get a new
b, and the bytes it forwards here may NOT be1, so--lenis not correct IIRC.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.
Oh, yeah, indeed. It seems number of bytes not number of items :-/