Skip to content

Commit 95375f1

Browse files
authored
Merge pull request uutils#10707 from nyurik/improve
chore: minor optimizations
2 parents b5a5c47 + 1ee1e49 commit 95375f1

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/uu/env/src/native_int_str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl<'a> Convert<&'a Vec<&'a str>, Vec<Cow<'a, NativeIntStr>>> for NCvt {
116116

117117
impl<'a> Convert<Vec<&'a str>, Vec<Cow<'a, NativeIntStr>>> for NCvt {
118118
fn convert(f: Vec<&'a str>) -> Vec<Cow<'a, NativeIntStr>> {
119-
f.iter().map(|x| Self::convert(*x)).collect()
119+
f.into_iter().map(Self::convert).collect()
120120
}
121121
}
122122

src/uu/ptx/src/ptx.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,14 @@ impl WordFilter {
133133
let break_set: Option<HashSet<char>> = if matches.contains_id(options::BREAK_FILE)
134134
&& !matches.contains_id(options::WORD_REGEXP)
135135
{
136-
let chars =
136+
let mut chars =
137137
read_char_filter_file(matches, options::BREAK_FILE).map_err_context(String::new)?;
138-
let mut hs: HashSet<char> = if config.gnu_ext {
139-
HashSet::new() // really only chars found in file
140-
} else {
138+
if !config.gnu_ext {
141139
// GNU off means at least these are considered
142-
[' ', '\t', '\n'].iter().copied().collect()
143-
};
144-
hs.extend(chars);
145-
Some(hs)
140+
chars.extend([' ', '\t', '\n']);
141+
}
142+
// else only chars found in file
143+
Some(chars)
146144
} else {
147145
// if -W takes precedence or default
148146
None

0 commit comments

Comments
 (0)