Use slices directly instead of &Vec (#10328)

Simplifies the signature, makes it more flexible.
Detected a few unnecessary allocations in the process.
This commit is contained in:
Stefan Holderbach
2023-09-12 05:38:20 +02:00
committed by GitHub
parent 84c10de864
commit e90b099622
17 changed files with 48 additions and 46 deletions

View File

@ -263,7 +263,7 @@ mod command_completions_tests {
(" hello sud", 1),
];
for (idx, ele) in commands.iter().enumerate() {
let index = find_non_whitespace_index(&Vec::from(ele.0.as_bytes()), 0);
let index = find_non_whitespace_index(ele.0.as_bytes(), 0);
assert_eq!(index, ele.1, "Failed on index {}", idx);
}
}

View File

@ -144,7 +144,7 @@ impl Highlighter for NuHighlighter {
fn split_span_by_highlight_positions(
line: &str,
span: Span,
highlight_positions: &Vec<usize>,
highlight_positions: &[usize],
global_span_offset: usize,
) -> Vec<(Span, bool)> {
let mut start = span.start;