Add optimized SSZ decoding for fixed-len items (#865)

* Add custom SSZ decode for Validator

* Move efficient decode into macro

* Don't allocate SSZ offset to heap

* Use smallvec in SszDecoder

* Fix test compile error
This commit is contained in:
Paul Hauner
2020-03-04 11:45:01 +11:00
committed by GitHub
parent 58fb144276
commit 871163aecc
6 changed files with 79 additions and 32 deletions

View File

@@ -221,9 +221,9 @@ impl<T: Encode> Encode for Option<T> {
fn ssz_append(&self, buf: &mut Vec<u8>) {
match self {
None => buf.append(&mut encode_union_index(0)),
None => buf.extend_from_slice(&encode_union_index(0)),
Some(t) => {
buf.append(&mut encode_union_index(1));
buf.extend_from_slice(&encode_union_index(1));
t.ssz_append(buf);
}
}