diff --git a/src/parser/lesser_block.rs b/src/parser/lesser_block.rs index f899c91..507a851 100644 --- a/src/parser/lesser_block.rs +++ b/src/parser/lesser_block.rs @@ -261,11 +261,10 @@ fn data<'s>(input: OrgSource<'s>) -> Res, 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"))]