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