Skip to content

Commit a774bc1

Browse files
committed
segwit: Inline functions
As we do, inline "small" public functions in the `segwit` module.
1 parent 1867dcf commit a774bc1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/segwit.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ use crate::write_err;
6565
/// let (_hrp, _witness_version, _witness_program) = segwit::decode(address).expect("failed to decode address");
6666
/// ```
6767
#[cfg(feature = "alloc")]
68+
#[inline]
6869
pub fn decode(s: &str) -> Result<(Hrp, Fe32, Vec<u8>), SegwitHrpstringError> {
6970
let segwit = SegwitHrpstring::new(s)?;
7071
Ok((segwit.hrp(), segwit.witness_version(), segwit.byte_iter().collect::<Vec<u8>>()))
@@ -85,6 +86,7 @@ pub fn decode(s: &str) -> Result<(Hrp, Fe32, Vec<u8>), SegwitHrpstringError> {
8586
/// [BIP-173]: <https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki>
8687
/// [BIP-350]: <https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki>
8788
#[cfg(feature = "alloc")]
89+
#[inline]
8890
pub fn encode(
8991
hrp: &Hrp,
9092
witness_version: Fe32,
@@ -100,12 +102,14 @@ pub fn encode(
100102

101103
/// Encodes a segwit version 0 address.
102104
#[cfg(feature = "alloc")]
105+
#[inline]
103106
pub fn encode_v0(hrp: &Hrp, witness_program: &[u8]) -> Result<String, EncodeError> {
104107
encode(hrp, VERSION_0, witness_program)
105108
}
106109

107110
/// Encodes a segwit version 1 address.
108111
#[cfg(feature = "alloc")]
112+
#[inline]
109113
pub fn encode_v1(hrp: &Hrp, witness_program: &[u8]) -> Result<String, EncodeError> {
110114
encode(hrp, VERSION_1, witness_program)
111115
}
@@ -114,6 +118,7 @@ pub fn encode_v1(hrp: &Hrp, witness_program: &[u8]) -> Result<String, EncodeErro
114118
///
115119
/// Does not check the validity of the witness version and witness program lengths (see
116120
/// the [`crate::primitives::segwit`] module for validation functions).
121+
#[inline]
117122
pub fn encode_to_fmt_unchecked<W: fmt::Write>(
118123
fmt: &mut W,
119124
hrp: &Hrp,
@@ -142,6 +147,7 @@ pub fn encode_to_fmt_unchecked<W: fmt::Write>(
142147
///
143148
/// Does not check the validity of the witness version and witness program lengths (see
144149
/// the [`crate::primitives::segwit`] module for validation functions).
150+
#[inline]
145151
pub fn encode_to_fmt_unchecked_uppercase<W: fmt::Write>(
146152
fmt: &mut W,
147153
hrp: &Hrp,

0 commit comments

Comments
 (0)