Skip to content

Commit

Permalink
passthrough and delegation does affect inlining, but we don't want it…
Browse files Browse the repository at this point in the history
… to. strongly inline low-level numeric encodings and passthrough impls
  • Loading branch information
mumbleskates committed Apr 14, 2024
1 parent 504680a commit 594f066
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
20 changes: 10 additions & 10 deletions src/encoding/fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@ macro_rules! fixed_width_common {
}

impl ValueEncoder<Fixed> for $ty {
#[inline]
#[inline(always)]
fn encode_value<B: BufMut + ?Sized>(value: &$ty, buf: &mut B) {
buf.$put(*value);
}

#[inline]
#[inline(always)]
fn prepend_value<B: ReverseBuf + ?Sized>(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<B: Buf + ?Sized>(
value: &mut $ty,
mut buf: Capped<B>,
Expand Down Expand Up @@ -75,7 +75,7 @@ macro_rules! fixed_width_int {
fixed_width_common!($ty, $wire_type, $put, $prepend, $get);

impl DistinguishedValueEncoder<Fixed> for $ty {
#[inline]
#[inline(always)]
fn decode_value_distinguished<const ALLOW_EMPTY: bool>(
value: &mut $ty,
buf: Capped<impl Buf + ?Sized>,
Expand Down Expand Up @@ -141,22 +141,22 @@ macro_rules! fixed_width_array {
}

impl ValueEncoder<Fixed> for [u8; $N] {
#[inline]
#[inline(always)]
fn encode_value<B: BufMut + ?Sized>(value: &[u8; $N], mut buf: &mut B) {
(&mut buf).put(value.as_slice());
}

#[inline]
#[inline(always)]
fn prepend_value<B: ReverseBuf + ?Sized>(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<B: Buf + ?Sized>(
value: &mut [u8; $N],
mut buf: Capped<B>,
Expand All @@ -171,7 +171,7 @@ macro_rules! fixed_width_array {
}

impl DistinguishedValueEncoder<Fixed> for [u8; $N] {
#[inline]
#[inline(always)]
fn decode_value_distinguished<const ALLOW_EMPTY: bool>(
value: &mut [u8; $N],
buf: Capped<impl Buf + ?Sized>,
Expand Down
32 changes: 16 additions & 16 deletions src/encoding/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,7 @@ macro_rules! delegate_encoding {
Self: $crate::encoding::Encoder<$to_ty>,
$($($where_clause)*)?
{
#[inline]
#[inline(always)]
fn encode<B: $crate::bytes::BufMut + ?Sized>(
tag: u32,
value: &$value_ty,
Expand All @@ -1776,7 +1776,7 @@ macro_rules! delegate_encoding {
$crate::encoding::Encoder::<$to_ty>::encode(tag, value, buf, tw)
}

#[inline]
#[inline(always)]
fn prepend_encode<B: $crate::buf::ReverseBuf + ?Sized>(
tag: u32,
value: &$value_ty,
Expand All @@ -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,
Expand All @@ -1795,7 +1795,7 @@ macro_rules! delegate_encoding {
$crate::encoding::Encoder::<$to_ty>::encoded_len(tag, value, tm)
}

#[inline]
#[inline(always)]
fn decode<B: $crate::bytes::Buf + ?Sized>(
wire_type: $crate::encoding::WireType,
duplicated: bool,
Expand Down Expand Up @@ -1832,7 +1832,7 @@ macro_rules! delegate_encoding {
+ $crate::encoding::Encoder<$to_ty>,
$($($where_clause)*)?
{
#[inline]
#[inline(always)]
fn decode_distinguished<B: $crate::bytes::Buf + ?Sized>(
wire_type: $crate::encoding::WireType,
duplicated: bool,
Expand Down Expand Up @@ -1874,25 +1874,25 @@ 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,
) {
$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,
Expand All @@ -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>,
Expand Down Expand Up @@ -1931,7 +1931,7 @@ macro_rules! delegate_value_encoding {
$($($expedient_where)+ ,)?
$($($distinguished_where)+ ,)?
{
#[inline]
#[inline(always)]
fn decode_value_distinguished<const ALLOW_EMPTY: bool>(
value: &mut $value_ty,
buf: $crate::encoding::Capped<impl Buf + ?Sized>,
Expand Down Expand Up @@ -1963,7 +1963,7 @@ macro_rules! encoder_where_value_encoder {
T: $crate::encoding::EmptyState + ValueEncoder<$encoding>,
$($($where_clause)*)?
{
#[inline]
#[inline(always)]
fn encode<B: BufMut + ?Sized>(
tag: u32,
value: &T,
Expand All @@ -1976,7 +1976,7 @@ macro_rules! encoder_where_value_encoder {
}
}

#[inline]
#[inline(always)]
fn prepend_encode<B: $crate::buf::ReverseBuf + ?Sized>(
tag: u32,
value: &T,
Expand All @@ -1989,7 +1989,7 @@ macro_rules! encoder_where_value_encoder {
}
}

#[inline]
#[inline(always)]
fn encoded_len(
tag: u32,
value: &T,
Expand All @@ -2003,7 +2003,7 @@ macro_rules! encoder_where_value_encoder {
}
}

#[inline]
#[inline(always)]
fn decode<B: Buf + ?Sized>(
wire_type: WireType,
duplicated: bool,
Expand Down Expand Up @@ -2031,7 +2031,7 @@ macro_rules! encoder_where_value_encoder {
+ $crate::encoding::Encoder<$encoding>,
$($($where_clause)*)?
{
#[inline]
#[inline(always)]
fn decode_distinguished<B: Buf + ?Sized>(
wire_type: WireType,
duplicated: bool,
Expand Down
8 changes: 4 additions & 4 deletions src/encoding/varint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,22 @@ macro_rules! varint {
}

impl ValueEncoder<Varint> for $ty {
#[inline]
#[inline(always)]
fn encode_value<B: BufMut + ?Sized>($to_uint64_value: &$ty, buf: &mut B) {
encode_varint($to_uint64, buf);
}

#[inline]
#[inline(always)]
fn prepend_value<B: ReverseBuf + ?Sized>($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<B: Buf + ?Sized>(
__value: &mut $ty,
mut buf: Capped<B>,
Expand Down

0 comments on commit 594f066

Please sign in to comment.