Browse Source

use unstable sort

edition-2021
Lynne Megido 3 months ago
parent
commit
a2ce336fe7
Signed by: lynnesbian
GPG Key ID: F0A184B5213D9F90
  1. 16
      src/formats.rs

16
src/formats.rs

@ -136,12 +136,12 @@ pub trait FormatSteps {
// sort errors so unreadable files appear before files with unknown mimetypes - ScanError impls Ord such that
// ScanError::File > ScanError::Mime
let errors = entries.iter().filter_map(|e| e.as_ref().err()).sorted();
let errors = entries.iter().filter_map(|e| e.as_ref().err()).sorted_unstable();
// sort files so that files with no known extension come before those with known extensions - None > Some("jpg")
let findings = entries
.iter()
.filter_map(|e| e.as_ref().ok())
.sorted_by(|a, b| b.recommended_extension().cmp(&a.recommended_extension()).reverse());
.sorted_unstable_by(|a, b| b.recommended_extension().cmp(&a.recommended_extension()).reverse());
for error in errors {
match error {
@ -343,8 +343,16 @@ impl Format for Json {
let result = serde_json::to_writer_pretty(
f,
&SerdeEntries {
errors: &entries.iter().filter_map(|e| e.as_ref().err()).sorted().collect(),
findings: &entries.iter().filter_map(|f| f.as_ref().ok()).sorted().collect(),
errors: &entries
.iter()
.filter_map(|e| e.as_ref().err())
.sorted_unstable()
.collect(),
findings: &entries
.iter()
.filter_map(|f| f.as_ref().ok())
.sorted_unstable()
.collect(),
},
);

Loading…
Cancel
Save