perf: improve rlp, update Address methods#118
Merged
Conversation
f020f12 to
6a24dcc
Compare
mattsse
approved these changes
Jun 16, 2023
Member
mattsse
left a comment
There was a problem hiding this comment.
tests look good, not exactly sure about the address encoding but seems alright
| } else if *self < <$t>::from(EMPTY_STRING_CODE) { | ||
| out.put_u8(u8::try_from(*self).unwrap()); | ||
| } else if x < EMPTY_STRING_CODE as $t { | ||
| out.put_u8(x as u8); |
Comment on lines
+296
to
+300
| // minus 1 to account for the list header itself | ||
| out[0] = EMPTY_LIST_CODE + len as u8 - 1; | ||
|
|
||
| // address header + address | ||
| out[1] = EMPTY_STRING_CODE + 20; |
Member
There was a problem hiding this comment.
i don't know rlp enough to comment on what's going on here
Member
Author
There was a problem hiding this comment.
It's basically just inlining Header { list: true, len: len - 1 }.encode() and self.encode()
I've added a proptest to verify this
6a24dcc to
4a0b889
Compare
prestwich
approved these changes
Jun 19, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
We can use
leading_zeros()to determine ahead of time how many bytes we need to skip, instead of iterating over the bytes and counting them.Assembly diff of
<u64 as Encodable>::encode: https://www.diffchecker.com/TxUdi1il/Solution
PR Checklist