Skip to content

Commit

Permalink
Signature data deduplication sort based off symbols before processing
Browse files Browse the repository at this point in the history
  • Loading branch information
emesare committed Nov 8, 2024
1 parent 2d296ad commit b4d59ec
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion rust/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ impl Data {
self.types.sort_by_key(|ty| ty.guid);
self.types.dedup_by_key(|ty| ty.guid);
// Sort and remove functions with the same symbol and guid.
self.functions.sort_by_key(|func| func.guid);
self.functions
.sort_by(|a, b| a.guid.cmp(&b.guid).then_with(|| a.symbol.cmp(&b.symbol)));
self.functions.dedup_by(|a, b| {
if a.guid == b.guid && a.symbol == b.symbol {
// Keep `a`s constraints.
Expand Down Expand Up @@ -182,6 +183,7 @@ mod tests {
vec![
create_sample_function("func2", FUNC3_GUID),
create_sample_function("func3", FUNC2_GUID),
create_sample_function("func2", FUNC2_GUID),
],
vec![
create_sample_computed_type(TYPE1_GUID),
Expand Down
2 changes: 1 addition & 1 deletion rust/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use flatbuffers::{FlatBufferBuilder, WIPOffset};

pub use fb::SymbolModifiers;

#[derive(Clone, Debug, Eq, PartialEq, Hash)]
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct Symbol {
pub name: String,
pub modifiers: SymbolModifiers,
Expand Down
2 changes: 1 addition & 1 deletion rust/symbol/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl DataSymbolClass {
}
}

#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub enum SymbolClass {
Function,
Data,
Expand Down

0 comments on commit b4d59ec

Please sign in to comment.