Override default visit_byte_buf on Script
This override may avoid allocation and thus make the deserialization faster. Credit to Kixunil for this fix: https://github.com/rust-bitcoin/rust-bitcoin/pull/905#issuecomment-1092756343
This commit is contained in:
parent
add100c20d
commit
76fcf81474
|
@ -1042,6 +1042,13 @@ impl<'de> serde::Deserialize<'de> for Script {
|
||||||
{
|
{
|
||||||
Ok(Script::from(v.to_vec()))
|
Ok(Script::from(v.to_vec()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E>
|
||||||
|
where
|
||||||
|
E: serde::de::Error,
|
||||||
|
{
|
||||||
|
Ok(Script::from(v))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
deserializer.deserialize_bytes(BytesVisitor)
|
deserializer.deserialize_bytes(BytesVisitor)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue