Skip to content

Commit e642a52

Browse files
committed
Add #[inline] to methods of SerializedSignatre
These methods are trivial so great candidates for inlining.
1 parent e92540b commit e642a52

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/ecdsa/serialized_signature.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ impl fmt::Display for SerializedSignature {
3434
}
3535

3636
impl Default for SerializedSignature {
37+
#[inline]
3738
fn default() -> SerializedSignature {
3839
SerializedSignature {
3940
data: [0u8; 72],
@@ -43,12 +44,14 @@ impl Default for SerializedSignature {
4344
}
4445

4546
impl PartialEq for SerializedSignature {
47+
#[inline]
4648
fn eq(&self, other: &SerializedSignature) -> bool {
4749
**self == **other
4850
}
4951
}
5052

5153
impl AsRef<[u8]> for SerializedSignature {
54+
#[inline]
5255
fn as_ref(&self) -> &[u8] {
5356
&*self
5457
}
@@ -57,6 +60,7 @@ impl AsRef<[u8]> for SerializedSignature {
5760
impl ops::Deref for SerializedSignature {
5861
type Target = [u8];
5962

63+
#[inline]
6064
fn deref(&self) -> &[u8] {
6165
&self.data[..self.len]
6266
}
@@ -78,45 +82,53 @@ impl<'a> IntoIterator for &'a SerializedSignature {
7882
type IntoIter = core::slice::Iter<'a, u8>;
7983
type Item = &'a u8;
8084

85+
#[inline]
8186
fn into_iter(self) -> Self::IntoIter {
8287
self.iter()
8388
}
8489
}
8590

8691
impl SerializedSignature {
8792
/// Get a pointer to the underlying data with the specified capacity.
93+
#[inline]
8894
pub(crate) fn get_data_mut_ptr(&mut self) -> *mut u8 {
8995
self.data.as_mut_ptr()
9096
}
9197

9298
/// Get the capacity of the underlying data buffer.
99+
#[inline]
93100
pub fn capacity(&self) -> usize {
94101
self.data.len()
95102
}
96103

97104
/// Get the len of the used data.
105+
#[inline]
98106
pub fn len(&self) -> usize {
99107
self.len
100108
}
101109

102110
/// Set the length of the object.
111+
#[inline]
103112
pub(crate) fn set_len(&mut self, len: usize) {
104113
self.len = len;
105114
}
106115

107116
/// Convert the serialized signature into the Signature struct.
108117
/// (This DER deserializes it)
118+
#[inline]
109119
pub fn to_signature(&self) -> Result<Signature, Error> {
110120
Signature::from_der(self)
111121
}
112122

113123
/// Create a SerializedSignature from a Signature.
114124
/// (this DER serializes it)
125+
#[inline]
115126
pub fn from_signature(sig: &Signature) -> SerializedSignature {
116127
sig.serialize_der()
117128
}
118129

119130
/// Check if the space is zero.
131+
#[inline]
120132
pub fn is_empty(&self) -> bool { self.len() == 0 }
121133
}
122134

0 commit comments

Comments
 (0)