Inline extract_prefix_and_unescape_yaml()

We sometimes call it but discard half its results, so force it to be inlined to
make sure we don't perform work we then throw away.
This commit is contained in:
Mahmoud Al-Qudsi 2024-05-17 16:10:54 -05:00
parent bcb1e2ed85
commit d8e9a17c1f

View File

@ -334,6 +334,10 @@ fn trim_leading_spaces(s: &[u8]) -> (usize, &[u8]) {
(count, &s[count..])
}
// This function is forcibly inlined because we sometimes call it but discard one of the return
// values. Hopefully that will be sufficient for the compiler to skip the unnecessary call to
// unescape_yaml_fish_2_0() for the discarded key.
#[inline(always)]
#[allow(clippy::type_complexity)]
fn extract_prefix_and_unescape_yaml(line: &[u8]) -> Option<(Cow<[u8]>, Cow<[u8]>)> {
let mut split = line.splitn(2, |c| *c == b':');