Skip to content

Commit 2a927d4

Browse files
author
ass3rt
committed
Override default visit_byte_buf on Script
This override may avoid allocation and thus make the deserialization faster. Credit to Kixunil for this fix: rust-bitcoin/rust-bitcoin#905 (comment)
1 parent 59b6d13 commit 2a927d4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/blockdata/script.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,13 @@ impl<'de> serde::Deserialize<'de> for Script {
10421042
{
10431043
Ok(Script::from(v.to_vec()))
10441044
}
1045+
1046+
fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E>
1047+
where
1048+
E: serde::de::Error,
1049+
{
1050+
Ok(Script::from(v))
1051+
}
10451052
}
10461053
deserializer.deserialize_bytes(BytesVisitor)
10471054
}

0 commit comments

Comments
 (0)