From 594f066b539a001580214f99d22ee0a46b34f950 Mon Sep 17 00:00:00 2001 From: Kent Ross Date: Sun, 14 Apr 2024 14:38:29 -0700 Subject: [PATCH] passthrough and delegation does affect inlining, but we don't want it to. strongly inline low-level numeric encodings and passthrough impls --- src/encoding/fixed.rs | 20 ++++++++++---------- src/encoding/mod.rs | 32 ++++++++++++++++---------------- src/encoding/varint.rs | 8 ++++---- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/encoding/fixed.rs b/src/encoding/fixed.rs index a89b98df..f0dfd172 100644 --- a/src/encoding/fixed.rs +++ b/src/encoding/fixed.rs @@ -32,22 +32,22 @@ macro_rules! fixed_width_common { } impl ValueEncoder for $ty { - #[inline] + #[inline(always)] fn encode_value(value: &$ty, buf: &mut B) { buf.$put(*value); } - #[inline] + #[inline(always)] fn prepend_value(value: &$ty, buf: &mut B) { buf.$prepend(*value); } - #[inline] + #[inline(always)] fn value_encoded_len(_value: &$ty) -> usize { WireType::$wire_type.fixed_size().unwrap() } - #[inline] + #[inline(always)] fn decode_value( value: &mut $ty, mut buf: Capped, @@ -75,7 +75,7 @@ macro_rules! fixed_width_int { fixed_width_common!($ty, $wire_type, $put, $prepend, $get); impl DistinguishedValueEncoder for $ty { - #[inline] + #[inline(always)] fn decode_value_distinguished( value: &mut $ty, buf: Capped, @@ -141,22 +141,22 @@ macro_rules! fixed_width_array { } impl ValueEncoder for [u8; $N] { - #[inline] + #[inline(always)] fn encode_value(value: &[u8; $N], mut buf: &mut B) { (&mut buf).put(value.as_slice()); } - #[inline] + #[inline(always)] fn prepend_value(value: &[u8; $N], buf: &mut B) { buf.prepend_slice(value.as_slice()); } - #[inline] + #[inline(always)] fn value_encoded_len(_value: &[u8; $N]) -> usize { $N } - #[inline] + #[inline(always)] fn decode_value( value: &mut [u8; $N], mut buf: Capped, @@ -171,7 +171,7 @@ macro_rules! fixed_width_array { } impl DistinguishedValueEncoder for [u8; $N] { - #[inline] + #[inline(always)] fn decode_value_distinguished( value: &mut [u8; $N], buf: Capped, diff --git a/src/encoding/mod.rs b/src/encoding/mod.rs index faa2495e..593499a1 100644 --- a/src/encoding/mod.rs +++ b/src/encoding/mod.rs @@ -1766,7 +1766,7 @@ macro_rules! delegate_encoding { Self: $crate::encoding::Encoder<$to_ty>, $($($where_clause)*)? { - #[inline] + #[inline(always)] fn encode( tag: u32, value: &$value_ty, @@ -1776,7 +1776,7 @@ macro_rules! delegate_encoding { $crate::encoding::Encoder::<$to_ty>::encode(tag, value, buf, tw) } - #[inline] + #[inline(always)] fn prepend_encode( tag: u32, value: &$value_ty, @@ -1786,7 +1786,7 @@ macro_rules! delegate_encoding { $crate::encoding::Encoder::<$to_ty>::prepend_encode(tag, value, buf, tw) } - #[inline] + #[inline(always)] fn encoded_len( tag: u32, value: &$value_ty, @@ -1795,7 +1795,7 @@ macro_rules! delegate_encoding { $crate::encoding::Encoder::<$to_ty>::encoded_len(tag, value, tm) } - #[inline] + #[inline(always)] fn decode( wire_type: $crate::encoding::WireType, duplicated: bool, @@ -1832,7 +1832,7 @@ macro_rules! delegate_encoding { + $crate::encoding::Encoder<$to_ty>, $($($where_clause)*)? { - #[inline] + #[inline(always)] fn decode_distinguished( wire_type: $crate::encoding::WireType, duplicated: bool, @@ -1874,12 +1874,12 @@ macro_rules! delegate_value_encoding { Self: $crate::encoding::ValueEncoder<$to_ty>, $($($where_clause)+ ,)? { - #[inline] + #[inline(always)] fn encode_value<__B: $crate::bytes::BufMut + ?Sized>(value: &$value_ty, buf: &mut __B) { $crate::encoding::ValueEncoder::<$to_ty>::encode_value(value, buf) } - #[inline] + #[inline(always)] fn prepend_value<__B: $crate::buf::ReverseBuf + ?Sized>( value: &$value_ty, buf: &mut __B, @@ -1887,12 +1887,12 @@ macro_rules! delegate_value_encoding { $crate::encoding::ValueEncoder::<$to_ty>::prepend_value(value, buf) } - #[inline] + #[inline(always)] fn value_encoded_len(value: &$value_ty) -> usize { $crate::encoding::ValueEncoder::<$to_ty>::value_encoded_len(value) } - #[inline] + #[inline(always)] fn many_values_encoded_len<__I>(values: __I) -> usize where __I: ExactSizeIterator, @@ -1901,7 +1901,7 @@ macro_rules! delegate_value_encoding { $crate::encoding::ValueEncoder::<$to_ty>::many_values_encoded_len(values) } - #[inline] + #[inline(always)] fn decode_value<__B: $crate::bytes::Buf + ?Sized>( value: &mut $value_ty, buf: $crate::encoding::Capped<__B>, @@ -1931,7 +1931,7 @@ macro_rules! delegate_value_encoding { $($($expedient_where)+ ,)? $($($distinguished_where)+ ,)? { - #[inline] + #[inline(always)] fn decode_value_distinguished( value: &mut $value_ty, buf: $crate::encoding::Capped, @@ -1963,7 +1963,7 @@ macro_rules! encoder_where_value_encoder { T: $crate::encoding::EmptyState + ValueEncoder<$encoding>, $($($where_clause)*)? { - #[inline] + #[inline(always)] fn encode( tag: u32, value: &T, @@ -1976,7 +1976,7 @@ macro_rules! encoder_where_value_encoder { } } - #[inline] + #[inline(always)] fn prepend_encode( tag: u32, value: &T, @@ -1989,7 +1989,7 @@ macro_rules! encoder_where_value_encoder { } } - #[inline] + #[inline(always)] fn encoded_len( tag: u32, value: &T, @@ -2003,7 +2003,7 @@ macro_rules! encoder_where_value_encoder { } } - #[inline] + #[inline(always)] fn decode( wire_type: WireType, duplicated: bool, @@ -2031,7 +2031,7 @@ macro_rules! encoder_where_value_encoder { + $crate::encoding::Encoder<$encoding>, $($($where_clause)*)? { - #[inline] + #[inline(always)] fn decode_distinguished( wire_type: WireType, duplicated: bool, diff --git a/src/encoding/varint.rs b/src/encoding/varint.rs index c3c17f28..d97893d3 100644 --- a/src/encoding/varint.rs +++ b/src/encoding/varint.rs @@ -66,22 +66,22 @@ macro_rules! varint { } impl ValueEncoder for $ty { - #[inline] + #[inline(always)] fn encode_value($to_uint64_value: &$ty, buf: &mut B) { encode_varint($to_uint64, buf); } - #[inline] + #[inline(always)] fn prepend_value($to_uint64_value: &$ty, buf: &mut B) { prepend_varint($to_uint64, buf); } - #[inline] + #[inline(always)] fn value_encoded_len($to_uint64_value: &$ty) -> usize { encoded_len_varint($to_uint64) } - #[inline] + #[inline(always)] fn decode_value( __value: &mut $ty, mut buf: Capped,