Add `#[inline]` to methods of `SerializedSignatre`
These methods are trivial so great candidates for inlining.
This commit is contained in:
parent
e92540beb8
commit
e642a52e7d
|
@ -34,6 +34,7 @@ impl fmt::Display for SerializedSignature {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for SerializedSignature {
|
impl Default for SerializedSignature {
|
||||||
|
#[inline]
|
||||||
fn default() -> SerializedSignature {
|
fn default() -> SerializedSignature {
|
||||||
SerializedSignature {
|
SerializedSignature {
|
||||||
data: [0u8; 72],
|
data: [0u8; 72],
|
||||||
|
@ -43,12 +44,14 @@ impl Default for SerializedSignature {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialEq for SerializedSignature {
|
impl PartialEq for SerializedSignature {
|
||||||
|
#[inline]
|
||||||
fn eq(&self, other: &SerializedSignature) -> bool {
|
fn eq(&self, other: &SerializedSignature) -> bool {
|
||||||
**self == **other
|
**self == **other
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsRef<[u8]> for SerializedSignature {
|
impl AsRef<[u8]> for SerializedSignature {
|
||||||
|
#[inline]
|
||||||
fn as_ref(&self) -> &[u8] {
|
fn as_ref(&self) -> &[u8] {
|
||||||
&*self
|
&*self
|
||||||
}
|
}
|
||||||
|
@ -57,6 +60,7 @@ impl AsRef<[u8]> for SerializedSignature {
|
||||||
impl ops::Deref for SerializedSignature {
|
impl ops::Deref for SerializedSignature {
|
||||||
type Target = [u8];
|
type Target = [u8];
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn deref(&self) -> &[u8] {
|
fn deref(&self) -> &[u8] {
|
||||||
&self.data[..self.len]
|
&self.data[..self.len]
|
||||||
}
|
}
|
||||||
|
@ -78,6 +82,7 @@ impl<'a> IntoIterator for &'a SerializedSignature {
|
||||||
type IntoIter = core::slice::Iter<'a, u8>;
|
type IntoIter = core::slice::Iter<'a, u8>;
|
||||||
type Item = &'a u8;
|
type Item = &'a u8;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn into_iter(self) -> Self::IntoIter {
|
fn into_iter(self) -> Self::IntoIter {
|
||||||
self.iter()
|
self.iter()
|
||||||
}
|
}
|
||||||
|
@ -85,38 +90,45 @@ impl<'a> IntoIterator for &'a SerializedSignature {
|
||||||
|
|
||||||
impl SerializedSignature {
|
impl SerializedSignature {
|
||||||
/// Get a pointer to the underlying data with the specified capacity.
|
/// Get a pointer to the underlying data with the specified capacity.
|
||||||
|
#[inline]
|
||||||
pub(crate) fn get_data_mut_ptr(&mut self) -> *mut u8 {
|
pub(crate) fn get_data_mut_ptr(&mut self) -> *mut u8 {
|
||||||
self.data.as_mut_ptr()
|
self.data.as_mut_ptr()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the capacity of the underlying data buffer.
|
/// Get the capacity of the underlying data buffer.
|
||||||
|
#[inline]
|
||||||
pub fn capacity(&self) -> usize {
|
pub fn capacity(&self) -> usize {
|
||||||
self.data.len()
|
self.data.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the len of the used data.
|
/// Get the len of the used data.
|
||||||
|
#[inline]
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
self.len
|
self.len
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the length of the object.
|
/// Set the length of the object.
|
||||||
|
#[inline]
|
||||||
pub(crate) fn set_len(&mut self, len: usize) {
|
pub(crate) fn set_len(&mut self, len: usize) {
|
||||||
self.len = len;
|
self.len = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert the serialized signature into the Signature struct.
|
/// Convert the serialized signature into the Signature struct.
|
||||||
/// (This DER deserializes it)
|
/// (This DER deserializes it)
|
||||||
|
#[inline]
|
||||||
pub fn to_signature(&self) -> Result<Signature, Error> {
|
pub fn to_signature(&self) -> Result<Signature, Error> {
|
||||||
Signature::from_der(self)
|
Signature::from_der(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a SerializedSignature from a Signature.
|
/// Create a SerializedSignature from a Signature.
|
||||||
/// (this DER serializes it)
|
/// (this DER serializes it)
|
||||||
|
#[inline]
|
||||||
pub fn from_signature(sig: &Signature) -> SerializedSignature {
|
pub fn from_signature(sig: &Signature) -> SerializedSignature {
|
||||||
sig.serialize_der()
|
sig.serialize_der()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if the space is zero.
|
/// Check if the space is zero.
|
||||||
|
#[inline]
|
||||||
pub fn is_empty(&self) -> bool { self.len() == 0 }
|
pub fn is_empty(&self) -> bool { self.len() == 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue