Remove an allocation for lesser block end.

This commit is contained in:
Tom Alexander 2023-09-22 00:55:10 -04:00
parent bd5e50d558
commit f7690ff64b
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -261,11 +261,10 @@ fn data<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
is_not("\r\n")(input)
}
fn lesser_block_end(current_name: &str) -> impl ContextMatcher {
let current_name_lower = current_name.to_lowercase();
move |context, input: OrgSource<'_>| {
_lesser_block_end(context, input, current_name_lower.as_str())
}
fn lesser_block_end<'c>(current_name: &'c str) -> impl ContextMatcher + 'c {
// Since the lesser block names are statically defined in code, we can simply assert that the name is lowercase instead of causing an allocation by converting to lowercase.
debug_assert!(current_name == current_name.to_lowercase());
move |context, input: OrgSource<'_>| _lesser_block_end(context, input, current_name)
}
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]