perf(header): add #[inline] to header! macros
This commit is contained in:
@@ -101,12 +101,14 @@ macro_rules! __hyper__deref {
|
|||||||
impl ::std::ops::Deref for $from {
|
impl ::std::ops::Deref for $from {
|
||||||
type Target = $to;
|
type Target = $to;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn deref(&self) -> &$to {
|
fn deref(&self) -> &$to {
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::ops::DerefMut for $from {
|
impl ::std::ops::DerefMut for $from {
|
||||||
|
#[inline]
|
||||||
fn deref_mut(&mut self) -> &mut $to {
|
fn deref_mut(&mut self) -> &mut $to {
|
||||||
&mut self.0
|
&mut self.0
|
||||||
}
|
}
|
||||||
@@ -201,14 +203,17 @@ macro_rules! header {
|
|||||||
static NAME: &'static str = $n;
|
static NAME: &'static str = $n;
|
||||||
NAME
|
NAME
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
fn parse_header(raw: &$crate::header::Raw) -> $crate::Result<Self> {
|
fn parse_header(raw: &$crate::header::Raw) -> $crate::Result<Self> {
|
||||||
$crate::header::parsing::from_comma_delimited(raw).map($id)
|
$crate::header::parsing::from_comma_delimited(raw).map($id)
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
fn fmt_header(&self, f: &mut $crate::header::Formatter) -> ::std::fmt::Result {
|
fn fmt_header(&self, f: &mut $crate::header::Formatter) -> ::std::fmt::Result {
|
||||||
f.fmt_line(self)
|
f.fmt_line(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl ::std::fmt::Display for $id {
|
impl ::std::fmt::Display for $id {
|
||||||
|
#[inline]
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
||||||
$crate::header::parsing::fmt_comma_delimited(f, &self.0[..])
|
$crate::header::parsing::fmt_comma_delimited(f, &self.0[..])
|
||||||
}
|
}
|
||||||
@@ -221,18 +226,22 @@ macro_rules! header {
|
|||||||
pub struct $id(pub Vec<$item>);
|
pub struct $id(pub Vec<$item>);
|
||||||
__hyper__deref!($id => Vec<$item>);
|
__hyper__deref!($id => Vec<$item>);
|
||||||
impl $crate::header::Header for $id {
|
impl $crate::header::Header for $id {
|
||||||
|
#[inline]
|
||||||
fn header_name() -> &'static str {
|
fn header_name() -> &'static str {
|
||||||
static NAME: &'static str = $n;
|
static NAME: &'static str = $n;
|
||||||
NAME
|
NAME
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
fn parse_header(raw: &$crate::header::Raw) -> $crate::Result<Self> {
|
fn parse_header(raw: &$crate::header::Raw) -> $crate::Result<Self> {
|
||||||
$crate::header::parsing::from_comma_delimited(raw).map($id)
|
$crate::header::parsing::from_comma_delimited(raw).map($id)
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
fn fmt_header(&self, f: &mut $crate::header::Formatter) -> ::std::fmt::Result {
|
fn fmt_header(&self, f: &mut $crate::header::Formatter) -> ::std::fmt::Result {
|
||||||
f.fmt_line(self)
|
f.fmt_line(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl ::std::fmt::Display for $id {
|
impl ::std::fmt::Display for $id {
|
||||||
|
#[inline]
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
||||||
$crate::header::parsing::fmt_comma_delimited(f, &self.0[..])
|
$crate::header::parsing::fmt_comma_delimited(f, &self.0[..])
|
||||||
}
|
}
|
||||||
@@ -245,20 +254,24 @@ macro_rules! header {
|
|||||||
pub struct $id(pub $value);
|
pub struct $id(pub $value);
|
||||||
__hyper__deref!($id => $value);
|
__hyper__deref!($id => $value);
|
||||||
impl $crate::header::Header for $id {
|
impl $crate::header::Header for $id {
|
||||||
|
#[inline]
|
||||||
fn header_name() -> &'static str {
|
fn header_name() -> &'static str {
|
||||||
static NAME: &'static str = $n;
|
static NAME: &'static str = $n;
|
||||||
NAME
|
NAME
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
fn parse_header(raw: &$crate::header::Raw) -> $crate::Result<Self> {
|
fn parse_header(raw: &$crate::header::Raw) -> $crate::Result<Self> {
|
||||||
$crate::header::parsing::from_one_raw_str(raw).map($id)
|
$crate::header::parsing::from_one_raw_str(raw).map($id)
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
fn fmt_header(&self, f: &mut $crate::header::Formatter) -> ::std::fmt::Result {
|
fn fmt_header(&self, f: &mut $crate::header::Formatter) -> ::std::fmt::Result {
|
||||||
f.fmt_line(self)
|
f.fmt_line(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl ::std::fmt::Display for $id {
|
impl ::std::fmt::Display for $id {
|
||||||
|
#[inline]
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
||||||
::std::fmt::Display::fmt(&**self, f)
|
::std::fmt::Display::fmt(&self.0, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -275,25 +288,30 @@ macro_rules! header {
|
|||||||
}
|
}
|
||||||
impl ::std::ops::Deref for $id {
|
impl ::std::ops::Deref for $id {
|
||||||
type Target = $value;
|
type Target = $value;
|
||||||
|
#[inline]
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&(self.0)
|
&(self.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl $crate::header::Header for $id {
|
impl $crate::header::Header for $id {
|
||||||
|
#[inline]
|
||||||
fn header_name() -> &'static str {
|
fn header_name() -> &'static str {
|
||||||
static NAME: &'static str = $n;
|
static NAME: &'static str = $n;
|
||||||
NAME
|
NAME
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
fn parse_header(raw: &$crate::header::Raw) -> $crate::Result<Self> {
|
fn parse_header(raw: &$crate::header::Raw) -> $crate::Result<Self> {
|
||||||
$crate::header::parsing::from_one_raw_str::<<$value as ::std::borrow::ToOwned>::Owned>(raw).map($id::new)
|
$crate::header::parsing::from_one_raw_str::<<$value as ::std::borrow::ToOwned>::Owned>(raw).map($id::new)
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
fn fmt_header(&self, f: &mut $crate::header::Formatter) -> ::std::fmt::Result {
|
fn fmt_header(&self, f: &mut $crate::header::Formatter) -> ::std::fmt::Result {
|
||||||
f.fmt_line(self)
|
f.fmt_line(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl ::std::fmt::Display for $id {
|
impl ::std::fmt::Display for $id {
|
||||||
|
#[inline]
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
||||||
::std::fmt::Display::fmt(&**self, f)
|
::std::fmt::Display::fmt(&self.0, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -308,10 +326,12 @@ macro_rules! header {
|
|||||||
Items(Vec<$item>),
|
Items(Vec<$item>),
|
||||||
}
|
}
|
||||||
impl $crate::header::Header for $id {
|
impl $crate::header::Header for $id {
|
||||||
|
#[inline]
|
||||||
fn header_name() -> &'static str {
|
fn header_name() -> &'static str {
|
||||||
static NAME: &'static str = $n;
|
static NAME: &'static str = $n;
|
||||||
NAME
|
NAME
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
fn parse_header(raw: &$crate::header::Raw) -> $crate::Result<Self> {
|
fn parse_header(raw: &$crate::header::Raw) -> $crate::Result<Self> {
|
||||||
// FIXME: Return None if no item is in $id::Only
|
// FIXME: Return None if no item is in $id::Only
|
||||||
if raw.len() == 1 {
|
if raw.len() == 1 {
|
||||||
@@ -321,11 +341,13 @@ macro_rules! header {
|
|||||||
}
|
}
|
||||||
$crate::header::parsing::from_comma_delimited(raw).map($id::Items)
|
$crate::header::parsing::from_comma_delimited(raw).map($id::Items)
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
fn fmt_header(&self, f: &mut $crate::header::Formatter) -> ::std::fmt::Result {
|
fn fmt_header(&self, f: &mut $crate::header::Formatter) -> ::std::fmt::Result {
|
||||||
f.fmt_line(self)
|
f.fmt_line(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl ::std::fmt::Display for $id {
|
impl ::std::fmt::Display for $id {
|
||||||
|
#[inline]
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
$id::Any => f.write_str("*"),
|
$id::Any => f.write_str("*"),
|
||||||
|
|||||||
Reference in New Issue
Block a user