Do not cast lesser block name to lowercase at runtime.
This reduced the runtime of my problematic test case from 6.9 seconds to 6 seconds.
This commit is contained in:
parent
ad3f47864a
commit
ae3510abd5
@ -265,13 +265,14 @@ fn _lesser_block_end<'r, 's, 'x>(
|
||||
Ok((remaining, source))
|
||||
}
|
||||
|
||||
fn lesser_block_begin(
|
||||
current_name: &str,
|
||||
/// Parser for the beginning of a lesser block
|
||||
///
|
||||
/// current_name MUST be lowercase. We do not do the conversion ourselves because it is not allowed in a const fn.
|
||||
const fn lesser_block_begin(
|
||||
current_name: &'static str,
|
||||
) -> impl for<'r, 's> Fn(Context<'r, 's>, OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
let current_name_lower = current_name.to_lowercase();
|
||||
move |context: Context, input: OrgSource<'_>| {
|
||||
_lesser_block_begin(context, input, current_name_lower.as_str())
|
||||
}
|
||||
// TODO: Since this is a const fn, is there ANY way to "generate" functions at compile time?
|
||||
move |context: Context, input: OrgSource<'_>| _lesser_block_begin(context, input, current_name)
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
|
Loading…
Reference in New Issue
Block a user