From 0567e6fe1d55a3473e83a28670e99010b6537729 Mon Sep 17 00:00:00 2001 From: Martin Habovstiak Date: Thu, 20 Feb 2025 16:18:21 +0100 Subject: [PATCH] Put `#[inline]` on most `Script{Buf}` methods These methods are either newtype casts that should compile to no-ops or directly calling into some other function with at most some pointer adjustments. As such making them `#[inline]` is definitely benefitial. There are also methods that check length and then call some other function. These are also worth inlining since the length could be known at compile time and the check could be eliminated. --- primitives/src/script/borrowed.rs | 3 +++ primitives/src/script/mod.rs | 39 +++++++++++++++++++++++++++++++ primitives/src/script/owned.rs | 10 ++++++++ 3 files changed, 52 insertions(+) diff --git a/primitives/src/script/borrowed.rs b/primitives/src/script/borrowed.rs index a2ba0f84b..29453482b 100644 --- a/primitives/src/script/borrowed.rs +++ b/primitives/src/script/borrowed.rs @@ -67,6 +67,7 @@ impl Default for &Script { impl ToOwned for Script { type Owned = ScriptBuf; + #[inline] fn to_owned(&self) -> Self::Owned { ScriptBuf::from_bytes(self.to_vec()) } } @@ -124,6 +125,7 @@ impl Script { /// Converts a [`Box