Skip to content

Commit 96ab8cd

Browse files
cgzonesetke
authored andcommitted
Simplifications
Push single elements into a vector instead appending a temporary wrapper vector.
1 parent a8142ea commit 96ab8cd

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/main.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ fn parse(file: &Path) -> Result<Vec<Binary>, Error> {
182182
} else {
183183
BinType::MachO32
184184
};
185-
fat_bins.append(&mut vec![Binary::new(
185+
fat_bins.push(Binary::new(
186186
bin_type,
187187
file.display().to_string(),
188188
BinSpecificProperties::MachO(results),
189-
)]);
189+
));
190190
}
191191
}
192192
}
@@ -326,10 +326,7 @@ fn main() {
326326
let mut procs: Vec<Process> = Vec::new();
327327
for (pid, proc_entry) in system.processes() {
328328
if let Ok(results) = parse(proc_entry.exe()) {
329-
procs.append(&mut vec![Process::new(
330-
pid.as_u32() as usize,
331-
results,
332-
)]);
329+
procs.push(Process::new(pid.as_u32() as usize, results));
333330
}
334331
}
335332
print_process_results(&Processes::new(procs), &settings);
@@ -370,10 +367,8 @@ fn main() {
370367

371368
match parse(process.exe()) {
372369
Ok(results) => {
373-
procs.append(&mut vec![Process::new(
374-
procid.as_u32() as usize,
375-
results,
376-
)]);
370+
procs
371+
.push(Process::new(procid.as_u32() as usize, results));
377372
}
378373
Err(msg) => {
379374
eprintln!(
@@ -396,10 +391,10 @@ fn main() {
396391
let mut procs: Vec<Process> = Vec::new();
397392
for proc_entry in sysprocs {
398393
if let Ok(results) = parse(proc_entry.exe()) {
399-
procs.append(&mut vec![Process::new(
394+
procs.push(Process::new(
400395
proc_entry.pid().as_u32() as usize,
401396
results,
402-
)]);
397+
));
403398
}
404399
}
405400
if procs.is_empty() {

0 commit comments

Comments
 (0)