mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-29 06:13:20 +00:00
Reserve vector capacity upfront in colors::named_color_names()
Only because why not.
This commit is contained in:
parent
fd2ea3ff0f
commit
f709795a3a
1 changed files with 7 additions and 4 deletions
11
src/color.rs
11
src/color.rs
|
@ -216,10 +216,13 @@ impl RgbColor {
|
||||||
|
|
||||||
/// Returns the names of all named colors.
|
/// Returns the names of all named colors.
|
||||||
pub fn named_color_names() -> Vec<&'static wstr> {
|
pub fn named_color_names() -> Vec<&'static wstr> {
|
||||||
let mut v: Vec<_> = NAMED_COLORS
|
// We don't use all the NAMED_COLORS but we also need room for one more.
|
||||||
.iter()
|
let mut v = Vec::with_capacity(NAMED_COLORS.len());
|
||||||
.filter_map(|&NamedColor { name, hidden, .. }| (!hidden).then_some(name))
|
v.extend(
|
||||||
.collect();
|
NAMED_COLORS
|
||||||
|
.iter()
|
||||||
|
.filter_map(|&NamedColor { name, hidden, .. }| (!hidden).then_some(name)),
|
||||||
|
);
|
||||||
|
|
||||||
// "normal" isn't really a color and does not have a color palette index or
|
// "normal" isn't really a color and does not have a color palette index or
|
||||||
// RGB value. Therefore, it does not appear in the NAMED_COLORS table.
|
// RGB value. Therefore, it does not appear in the NAMED_COLORS table.
|
||||||
|
|
Loading…
Reference in a new issue