Skip to content

Commit

Permalink
Override default visit_byte_buf on Script
Browse files Browse the repository at this point in the history
This override may avoid allocation and thus make the deserialization
faster.

Credit to Kixunil for this fix: #905 (comment)
  • Loading branch information
ass3rt committed Apr 25, 2022
1 parent add100c commit 76fcf81
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/blockdata/script.rs
Expand Up @@ -1042,6 +1042,13 @@ impl<'de> serde::Deserialize<'de> for Script {
{
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)
}
Expand Down

0 comments on commit 76fcf81

Please sign in to comment.