Skip to content

Commit 9613013

Browse files
committed
Remove an unnecessary sort call.
1 parent 374b605 commit 9613013

File tree

1 file changed

+11
-16
lines changed
  • samply-api/src/symbolicate

1 file changed

+11
-16
lines changed

samply-api/src/symbolicate/mod.rs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl<'a, H: FileAndPathHelper + 'static> SymbolicateApi<'a, H> {
6262
let mut symbolicated_addresses = HashMap::new();
6363
for (lib, addresses) in requested_addresses.into_iter() {
6464
let address_results = self
65-
.symbolicate_requested_addresses_for_lib(&lib, addresses)
65+
.symbolicate_requested_addresses_for_lib(&lib, &addresses)
6666
.await;
6767
symbolicated_addresses.insert(lib, address_results);
6868
}
@@ -72,35 +72,30 @@ impl<'a, H: FileAndPathHelper + 'static> SymbolicateApi<'a, H> {
7272
async fn symbolicate_requested_addresses_for_lib(
7373
&self,
7474
lib: &Lib,
75-
mut addresses: Vec<u32>,
75+
addresses: &[u32],
7676
) -> Result<PerLibResult<H>, samply_symbols::Error> {
77-
// Sort the addresses before the lookup, to have a higher chance of hitting
78-
// the same external file for subsequent addresses.
79-
addresses.sort_unstable();
80-
addresses.dedup();
81-
8277
let debug_id = to_debug_id(&lib.breakpad_id)?;
8378

84-
let mut external_addresses = Vec::new();
85-
86-
// Do the synchronous work first, and accumulate external_addresses which need
87-
// to be handled asynchronously. This allows us to group async file loads by
88-
// the external file.
89-
9079
let info = LibraryInfo {
9180
debug_name: Some(lib.debug_name.to_string()),
9281
debug_id: Some(debug_id),
9382
..Default::default()
9483
};
9584
let symbol_map = self.symbol_manager.load_symbol_map(&info).await?;
96-
symbol_map.set_access_pattern_hint(AccessPatternHint::SequentialLookup);
9785

86+
// Create a BTreeMap for the lookup results. This lets us iterate over the
87+
// addresses in ascending order - the sort happens when the map is created.
9888
let mut address_results: AddressResults =
9989
addresses.iter().map(|&addr| (addr, None)).collect();
90+
symbol_map.set_access_pattern_hint(AccessPatternHint::SequentialLookup);
10091

101-
for &address in &addresses {
92+
// Do the synchronous work first, and accumulate external_addresses which need
93+
// to be handled asynchronously. This allows us to group async file loads by
94+
// the external file.
95+
let mut external_addresses = Vec::new();
96+
97+
for (&address, address_result) in &mut address_results {
10298
if let Some(address_info) = symbol_map.lookup_sync(LookupAddress::Relative(address)) {
103-
let address_result = address_results.get_mut(&address).unwrap();
10499
*address_result = Some(AddressResult::new(
105100
address_info.symbol.address,
106101
address_info.symbol.name,

0 commit comments

Comments
 (0)