MCPcopy Create free account
hub / github.com/encounter/objdiff / matching_sections

Function matching_sections

objdiff-core/src/diff/mod.rs:763–797  ·  view source on GitHub ↗

Find matching sections between each object.

(left: Option<&Object>, right: Option<&Object>)

Source from the content-addressed store, hash-verified

761
762/// Find matching sections between each object.
763fn matching_sections(left: Option<&Object>, right: Option<&Object>) -> Result<Vec<SectionMatch>> {
764 let mut matches = Vec::with_capacity(
765 left.as_ref()
766 .map_or(0, |o| o.sections.len())
767 .max(right.as_ref().map_or(0, |o| o.sections.len())),
768 );
769 if let Some(left) = left {
770 for (section_idx, section) in left.sections.iter().enumerate() {
771 if section.kind == SectionKind::Unknown {
772 continue;
773 }
774 matches.push(SectionMatch {
775 left: Some(section_idx),
776 right: find_section(right, &section.name, section.kind, &matches),
777 section_kind: section.kind,
778 });
779 }
780 }
781 if let Some(right) = right {
782 for (section_idx, section) in right.sections.iter().enumerate() {
783 if section.kind == SectionKind::Unknown {
784 continue;
785 }
786 if matches.iter().any(|m| m.right == Some(section_idx)) {
787 continue;
788 }
789 matches.push(SectionMatch {
790 left: None,
791 right: Some(section_idx),
792 section_kind: section.kind,
793 });
794 }
795 }
796 Ok(matches)
797}
798
799fn find_section(
800 obj: Option<&Object>,

Callers 1

diff_objsFunction · 0.85

Calls 2

find_sectionFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected