history: Check for cmd key earlier

This shows up hot in `perf record ./fish` style profiles.

This assumes that "- cmd" can't be escaped.
This commit is contained in:
Fabian Boehm 2024-05-07 20:17:05 +02:00
parent f709795a3a
commit 41a0fe2b1d

View File

@ -331,12 +331,13 @@ fn extract_prefix_and_unescape_yaml(line: &[u8]) -> Option<(Vec<u8>, Vec<u8>)> {
fn decode_item_fish_2_0(mut data: &[u8]) -> Option<HistoryItem> {
let (advance, line) = read_line(data);
let line = trim_start(line);
let (key, value) = extract_prefix_and_unescape_yaml(line)?;
if key != b"- cmd" {
// Check this early *before* anything else.
if !line.starts_with(b"- cmd") {
return None;
}
let (_key, value) = extract_prefix_and_unescape_yaml(line)?;
data = &data[advance..];
let cmd = str2wcstring(&value);