Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions src/commands/debug_files/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ fn find_ids_for_dsym(
if dirent.path().extension() != Some(OsStr::new("class"));
if let Ok(dif) = DifFile::open_path(dirent.path(), Some(DifType::Dsym));
then {
return Some(extract_remaining_ids(&dif.ids(), remaining, DifType::Dsym))
return Some(extract_remaining_ids(dif.ids(), remaining, DifType::Dsym))
}
}
None
Expand All @@ -237,7 +237,7 @@ fn find_ids_for_elf(
if_chain! {
if let Ok(dif) = DifFile::open_path(dirent.path(), Some(DifType::Elf));
then {
return Some(extract_remaining_ids(&dif.ids(), remaining, DifType::Elf))
return Some(extract_remaining_ids(dif.ids(), remaining, DifType::Elf))
}
}
None
Expand All @@ -252,7 +252,7 @@ fn find_ids_for_pe(
dirent.path().extension() == Some(OsStr::new("dll"));
if let Ok(dif) = DifFile::open_path(dirent.path(), Some(DifType::Pe));
then {
return Some(extract_remaining_ids(&dif.ids(), remaining, DifType::Pe))
return Some(extract_remaining_ids(dif.ids(), remaining, DifType::Pe))
}
}
None
Expand All @@ -266,7 +266,7 @@ fn find_ids_for_pdb(
if dirent.path().extension() == Some(OsStr::new("pdb"));
if let Ok(dif) = DifFile::open_path(dirent.path(), Some(DifType::Pdb));
then {
return Some(extract_remaining_ids(&dif.ids(), remaining, DifType::Pdb))
return Some(extract_remaining_ids(dif.ids(), remaining, DifType::Pdb))
}
}
None
Expand All @@ -280,7 +280,7 @@ fn find_ids_for_portablepdb(
if dirent.path().extension() == Some(OsStr::new("pdb"));
if let Ok(dif) = DifFile::open_path(dirent.path(), Some(DifType::PortablePdb));
then {
return Some(extract_remaining_ids(&dif.ids(), remaining, DifType::PortablePdb))
return Some(extract_remaining_ids(dif.ids(), remaining, DifType::PortablePdb))
}
}
None
Expand All @@ -294,7 +294,7 @@ fn find_ids_for_sourcebundle(
if dirent.path().extension() == Some(OsStr::new("zip"));
if let Ok(dif) = DifFile::open_path(dirent.path(), Some(DifType::SourceBundle));
then {
return Some(extract_remaining_ids(&dif.ids(), remaining, DifType::SourceBundle))
return Some(extract_remaining_ids(dif.ids(), remaining, DifType::SourceBundle))
}
}
None
Expand All @@ -308,25 +308,27 @@ fn find_ids_for_breakpad(
if dirent.path().extension() == Some(OsStr::new("sym"));
if let Ok(dif) = DifFile::open_path(dirent.path(), Some(DifType::Breakpad));
then {
return Some(extract_remaining_ids(&dif.ids(), remaining, DifType::Breakpad))
return Some(extract_remaining_ids(dif.ids(), remaining, DifType::Breakpad))
}
}
None
}

fn extract_remaining_ids(
ids: &[DebugId],
fn extract_remaining_ids<I>(
ids: I,
remaining: &HashSet<DebugId>,
t: DifType,
) -> Vec<(DebugId, DifType)> {
ids.iter()
.filter_map(|id| {
if remaining.contains(id) {
return Some((id.to_owned(), t));
}
None
})
.collect()
) -> Vec<(DebugId, DifType)>
where
I: Iterator<Item = DebugId>,
{
ids.filter_map(|id| {
if remaining.contains(&id) {
return Some((id.to_owned(), t));
}
None
})
.collect()
}

pub fn execute(matches: &ArgMatches) -> Result<()> {
Expand Down
27 changes: 15 additions & 12 deletions src/utils/dif.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::fmt;
use std::path::Path;
use std::str;
use std::{fmt, iter};

use anyhow::{bail, Context as _, Error, Result};
use proguard::ProguardMapping;
Expand Down Expand Up @@ -327,16 +327,19 @@ impl<'a> DifFile<'a> {
}
}

pub fn ids(&self) -> Vec<DebugId> {
match self {
DifFile::Archive(archive) => archive
.get()
.objects()
.filter_map(Result::ok)
.map(|object| object.debug_id())
.collect(),
DifFile::Proguard(pg) => vec![pg.get().uuid().into()],
}
pub fn ids(&self) -> impl Iterator<Item = DebugId> + '_ {
let rv: Box<dyn Iterator<Item = _>> = match self {
DifFile::Archive(archive) => Box::new(
archive
.get()
.objects()
.filter_map(Result::ok)
.map(|object| object.debug_id()),
),
DifFile::Proguard(pg) => Box::new(iter::once(pg.get().uuid().into())),
};

rv
}

pub fn features(&self) -> ObjectDifFeatures {
Expand Down Expand Up @@ -407,7 +410,7 @@ impl<'a> DifFile<'a> {
}

fn has_ids(&self) -> bool {
self.ids().iter().any(|id| !id.is_nil())
self.ids().any(|id| !id.is_nil())
}
}

Expand Down