Skip to content

Commit

Permalink
Merge pull request #151 from zheland/issue_145
Browse files Browse the repository at this point in the history
Make inlining consistent between API methods.
  • Loading branch information
Alexhuszagh authored Sep 17, 2024
2 parents 7640e15 + df1a897 commit 47bac73
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
6 changes: 1 addition & 5 deletions lexical-parse-integer/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@ use crate::parse::ParseInteger;
/// can actually be evaluated at compile-time, which causes major branching
/// issues.
macro_rules! integer_from_lexical {
($($t:ident $unsigned:ident $(, #[$meta:meta])? ; )*) => ($(
($($t:ident $unsigned:ident ; )*) => ($(
impl FromLexical for $t {
$(#[$meta:meta])?
#[cfg_attr(not(feature = "compact"), inline)]
fn from_lexical(bytes: &[u8]) -> lexical_util::result::Result<Self>
{
Self::parse_complete::<STANDARD>(bytes, &DEFAULT_OPTIONS)
}

$(#[$meta:meta])?
#[cfg_attr(not(feature = "compact"), inline)]
fn from_lexical_partial(
bytes: &[u8],
Expand All @@ -37,7 +35,6 @@ macro_rules! integer_from_lexical {
impl FromLexicalWithOptions for $t {
type Options = Options;

$(#[$meta:meta])?
#[cfg_attr(not(feature = "compact"), inline)]
fn from_lexical_with_options<const FORMAT: u128>(
bytes: &[u8],
Expand All @@ -51,7 +48,6 @@ macro_rules! integer_from_lexical {
Self::parse_complete::<FORMAT>(bytes, options)
}

$(#[$meta:meta])?
#[cfg_attr(not(feature = "compact"), inline)]
fn from_lexical_partial_with_options<const FORMAT: u128>(
bytes: &[u8],
Expand Down
6 changes: 3 additions & 3 deletions lexical-write-float/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ const DEFAULT_OPTIONS: Options = Options::new();

// Implement ToLexical for numeric type.
macro_rules! float_to_lexical {
($($t:tt $(, #[$meta:meta])? ; )*) => ($(
($($t:tt ; )*) => ($(
impl ToLexical for $t {
$(#[$meta:meta])?
#[cfg_attr(not(feature = "compact"), inline)]
fn to_lexical(self, bytes: &mut [u8])
-> &mut [u8]
{
Expand All @@ -31,7 +31,7 @@ macro_rules! float_to_lexical {

impl ToLexicalWithOptions for $t {
type Options = Options;
$(#[$meta:meta])?
#[cfg_attr(not(feature = "compact"), inline)]
fn to_lexical_with_options<'a, const FORMAT: u128>(
self,
bytes: &'a mut [u8],
Expand Down
15 changes: 6 additions & 9 deletions lexical-write-integer/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ where

// Implement ToLexical for numeric type.
macro_rules! unsigned_to_lexical {
($($narrow:tt $wide:tt $(, #[$meta:meta])? ; )*) => ($(
($($narrow:tt $wide:tt ; )*) => ($(
impl ToLexical for $narrow {
$(#[$meta:meta])?
#[cfg_attr(not(feature = "compact"), inline)]
fn to_lexical(self, bytes: &mut [u8])
-> &mut [u8]
{
Expand All @@ -88,7 +88,7 @@ macro_rules! unsigned_to_lexical {
impl ToLexicalWithOptions for $narrow {
type Options = Options;

$(#[$meta:meta])?
#[cfg_attr(not(feature = "compact"), inline)]
fn to_lexical_with_options<'a, const FORMAT: u128>(
self,
bytes: &'a mut [u8],
Expand Down Expand Up @@ -122,11 +122,9 @@ unsigned_to_lexical! { usize u64 ; }

// Implement ToLexical for numeric type.
macro_rules! signed_to_lexical {
($($narrow:tt $wide:tt $unsigned:tt $(, #[$meta:meta])? ; )*) => ($(
($($narrow:tt $wide:tt $unsigned:tt ; )*) => ($(
impl ToLexical for $narrow {
$(#[$meta:meta])?
$(#[$meta:meta])?
#[inline]
#[cfg_attr(not(feature = "compact"), inline)]
fn to_lexical(self, bytes: &mut [u8])
-> &mut [u8]
{
Expand All @@ -137,8 +135,7 @@ macro_rules! signed_to_lexical {

impl ToLexicalWithOptions for $narrow {
type Options = Options;
$(#[$meta:meta])?
#[inline]
#[cfg_attr(not(feature = "compact"), inline)]
fn to_lexical_with_options<'a, const FORMAT: u128>(
self,
bytes: &'a mut [u8],
Expand Down

0 comments on commit 47bac73

Please sign in to comment.