-
Notifications
You must be signed in to change notification settings - Fork 178
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
perf: improve rlp, update Address methods #118
Conversation
f020f12
to
6a24dcc
Compare
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.
UTACK
cc @mattsse who is more familiar with this code
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.
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); |
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 check guarantees this
// 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; |
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.
i don't know rlp enough to comment on what's going on here
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.
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
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