mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(db): simplify Compact for Vec (#11361)
This commit is contained in:
@ -150,21 +150,7 @@ where
|
|||||||
where
|
where
|
||||||
B: bytes::BufMut + AsMut<[u8]>,
|
B: bytes::BufMut + AsMut<[u8]>,
|
||||||
{
|
{
|
||||||
encode_varuint(self.len(), buf);
|
self.as_slice().to_compact(buf)
|
||||||
|
|
||||||
let mut tmp: Vec<u8> = Vec::with_capacity(64);
|
|
||||||
|
|
||||||
for element in self {
|
|
||||||
tmp.clear();
|
|
||||||
|
|
||||||
// We don't know the length until we compact it
|
|
||||||
let length = element.to_compact(&mut tmp);
|
|
||||||
encode_varuint(length, buf);
|
|
||||||
|
|
||||||
buf.put_slice(&tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -190,11 +176,7 @@ where
|
|||||||
where
|
where
|
||||||
B: bytes::BufMut + AsMut<[u8]>,
|
B: bytes::BufMut + AsMut<[u8]>,
|
||||||
{
|
{
|
||||||
encode_varuint(self.len(), buf);
|
self.as_slice().specialized_to_compact(buf)
|
||||||
for element in self {
|
|
||||||
element.to_compact(buf);
|
|
||||||
}
|
|
||||||
0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// To be used by fixed sized types like `Vec<B256>`.
|
/// To be used by fixed sized types like `Vec<B256>`.
|
||||||
|
|||||||
Reference in New Issue
Block a user