From 9af1f1d1a9a6cf2a059ef0c822814bed1c324f8e Mon Sep 17 00:00:00 2001 From: kkent030315 Date: Thu, 12 Dec 2024 07:28:50 +0900 Subject: [PATCH] Simplify entry id identification --- src/pe/resource.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pe/resource.rs b/src/pe/resource.rs index 49f90598..ddad5f26 100644 --- a/src/pe/resource.rs +++ b/src/pe/resource.rs @@ -1148,10 +1148,10 @@ impl<'a> VersionInfo<'a> { file_alignment: u32, opts: &options::ParseOptions, ) -> error::Result> { - let it = it.collect::, _>>()?; - let it = it.iter().find(|e| e.id() == Some(RT_VERSION)); - - if let Some(entry) = it { + if let Some(entry) = it + .filter_map(|x| x.ok()) + .find(|x| x.id() == Some(RT_VERSION)) + { let offset_to_data = match entry.recursive_next_depth(bytes, |e| e.offset_to_data().is_none())? { Some(next) => match next.offset_to_data() { @@ -1226,10 +1226,10 @@ impl<'a> ManifestData<'a> { file_alignment: u32, opts: &options::ParseOptions, ) -> error::Result> { - let it = it.collect::, _>>()?; - let it = it.iter().find(|e| e.id() == Some(RT_MANIFEST)); - - if let Some(entry) = it { + if let Some(entry) = it + .filter_map(|x| x.ok()) + .find(|x| x.id() == Some(RT_VERSION)) + { let offset_to_data = match entry.recursive_next_depth(bytes, |e| e.offset_to_data().is_none())? { Some(next) => match next.offset_to_data() {