From 76fcf814745649c20d17e30515ae4f719eebff91 Mon Sep 17 00:00:00 2001 From: ass3rt Date: Mon, 25 Apr 2022 09:48:36 -0500 Subject: [PATCH] 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 --- src/blockdata/script.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/blockdata/script.rs b/src/blockdata/script.rs index a1dedb63..7f83bc9d 100644 --- a/src/blockdata/script.rs +++ b/src/blockdata/script.rs @@ -1042,6 +1042,13 @@ impl<'de> serde::Deserialize<'de> for Script { { Ok(Script::from(v.to_vec())) } + + fn visit_byte_buf(self, v: Vec) -> Result + where + E: serde::de::Error, + { + Ok(Script::from(v)) + } } deserializer.deserialize_bytes(BytesVisitor) }