Skip to content

Commit 796d76d

Browse files
committed
perf: inlining specializable methods
Signed-off-by: Liam Gray <[email protected]>
1 parent c637e7b commit 796d76d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

ciborium-ll/src/enc.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,26 @@ impl<W: Write> From<W> for Encoder<W> {
1818
impl<W: Write> Write for Encoder<W> {
1919
type Error = W::Error;
2020

21+
#[inline]
2122
fn write_all(&mut self, data: &[u8]) -> Result<(), Self::Error> {
2223
self.0.write_all(data)
2324
}
2425

26+
#[inline]
2527
fn flush(&mut self) -> Result<(), Self::Error> {
2628
self.0.flush()
2729
}
2830
}
2931

3032
impl<W: Write> Encoder<W> {
3133
/// Unwraps the `Write`, consuming the `Encoder`.
34+
#[inline]
3235
pub fn into_inner(self) -> W {
3336
self.0
3437
}
3538

3639
/// Push a `Header` to the wire
37-
#[inline]
40+
#[inline(always)]
3841
pub fn push(&mut self, header: Header) -> Result<(), W::Error> {
3942
let title = Title::from(header);
4043

ciborium-ll/src/hdr.rs

+2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ pub enum Header {
7575
impl TryFrom<Title> for Header {
7676
type Error = InvalidError;
7777

78+
#[inline]
7879
fn try_from(title: Title) -> Result<Self, Self::Error> {
7980
let opt = |minor| {
8081
Some(match minor {
@@ -116,6 +117,7 @@ impl TryFrom<Title> for Header {
116117
}
117118

118119
impl From<Header> for Title {
120+
#[inline(always)]
119121
fn from(header: Header) -> Self {
120122
let int = |i: u64| match i {
121123
x if x <= 23 => Minor::This(i as u8),

0 commit comments

Comments
 (0)