mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 08:40:38 +08:00
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:
parent
f709795a3a
commit
41a0fe2b1d
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user