Remove some unnecessary static Vecs (#11947)

Avoid unnecessary allocations or larger iterator structs

- Turn static `Vec`s into arrays when possible
- Use `std::iter::once`/`empty` where applicable
- Use `bool::then_some` in `detect column` `.chain`
- Drop in the bucket: de-vec-ing tests
This commit is contained in:
Stefan Holderbach
2024-02-24 20:58:01 +01:00
committed by GitHub
parent 098527b263
commit 7884de1941
10 changed files with 115 additions and 113 deletions

View File

@ -253,7 +253,7 @@ mod command_completions_tests {
#[test]
fn test_find_non_whitespace_index() {
let commands = vec![
let commands = [
(" hello", 4),
("sudo ", 0),
(" sudo ", 2),
@ -273,7 +273,7 @@ mod command_completions_tests {
#[test]
fn test_is_last_command_passthrough() {
let commands = vec![
let commands = [
(" hello", false),
(" sudo ", true),
("sudo ", true),

View File

@ -564,7 +564,7 @@ mod completer_tests {
);
let mut completer = NuCompleter::new(engine_state.into(), Stack::new());
let dataset = vec![
let dataset = [
("sudo", false, "", Vec::new()),
("sudo l", true, "l", vec!["ls", "let", "lines", "loop"]),
(" sudo", false, "", Vec::new()),

View File

@ -84,7 +84,7 @@ pub(crate) fn add_menus(
}
// Checking if the default menus have been added from the config file
let default_menus = vec![
let default_menus = [
("completion_menu", DEFAULT_COMPLETION_MENU),
("history_menu", DEFAULT_HISTORY_MENU),
("help_menu", DEFAULT_HELP_MENU),