No performance change switching affiliated_key to using element macro.
This commit is contained in:
parent
72b4cf8e71
commit
f10efec21d
@ -27,6 +27,7 @@ use crate::context::RefContext;
|
|||||||
use crate::error::CustomError;
|
use crate::error::CustomError;
|
||||||
use crate::error::MyError;
|
use crate::error::MyError;
|
||||||
use crate::error::Res;
|
use crate::error::Res;
|
||||||
|
use crate::parser::macros::element;
|
||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
use crate::types::AffiliatedKeywords;
|
use crate::types::AffiliatedKeywords;
|
||||||
use crate::types::Keyword;
|
use crate::types::Keyword;
|
||||||
@ -151,11 +152,12 @@ fn affiliated_key<'b, 'g, 'r, 's>(
|
|||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||||
alt((
|
element!(dual_affiliated_key, context, input);
|
||||||
parser_with_context!(dual_affiliated_key)(context),
|
element!(plain_affiliated_key, context, input);
|
||||||
parser_with_context!(plain_affiliated_key)(context),
|
element!(export_keyword, input);
|
||||||
export_keyword,
|
Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||||
))(input)
|
"No affiliated key.",
|
||||||
|
))))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
|
@ -35,6 +35,11 @@ macro_rules! element {
|
|||||||
return Ok((remaining, ele));
|
return Ok((remaining, ele));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
($parser:expr, $input: expr) => {
|
||||||
|
if let Ok((remaining, ele)) = $parser($input) {
|
||||||
|
return Ok((remaining, ele));
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) use element;
|
pub(crate) use element;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user