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:
Tom Alexander 2023-08-24 20:10:43 -04:00
parent ad3f47864a
commit ae3510abd5
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -265,13 +265,14 @@ fn _lesser_block_end<'r, 's, 'x>(
Ok((remaining, source)) Ok((remaining, source))
} }
fn lesser_block_begin( /// Parser for the beginning of a lesser block
current_name: &str, ///
/// 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>> { ) -> impl for<'r, 's> Fn(Context<'r, 's>, OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
let current_name_lower = current_name.to_lowercase(); // TODO: Since this is a const fn, is there ANY way to "generate" functions at compile time?
move |context: Context, input: OrgSource<'_>| { move |context: Context, input: OrgSource<'_>| _lesser_block_begin(context, input, current_name)
_lesser_block_begin(context, input, current_name_lower.as_str())
}
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]