Skip to content

Commit 0306d93

Browse files
committed
Remove unused code for diffing sections
1 parent d1a8679 commit 0306d93

File tree

1 file changed

+10
-63
lines changed

1 file changed

+10
-63
lines changed

objdiff-gui/src/views/diff.rs

Lines changed: 10 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use egui::{Id, Layout, RichText, ScrollArea, TextEdit, Ui, Widget, text::LayoutJ
22
use objdiff_core::{
33
build::BuildStatus,
44
diff::{
5-
DiffObjConfig, ObjectDiff, SectionDiff, SymbolDiff,
5+
DiffObjConfig, ObjectDiff, SymbolDiff,
66
display::{ContextItem, HoverItem, HoverItemColor, SymbolFilter, SymbolNavigationKind},
77
},
8-
obj::{Object, Section, Symbol},
8+
obj::{Object, Symbol},
99
};
1010
use time::format_description;
1111

@@ -34,7 +34,6 @@ enum SelectedSymbol {
3434
struct DiffColumnContext<'a> {
3535
status: &'a BuildStatus,
3636
obj: Option<&'a (Object, ObjectDiff)>,
37-
section: Option<(&'a Section, &'a SectionDiff, usize)>,
3837
symbol: Option<(&'a Symbol, &'a SymbolDiff, usize)>,
3938
}
4039

@@ -54,30 +53,21 @@ impl<'a> DiffColumnContext<'a> {
5453
_ => None,
5554
},
5655
};
57-
let (section, symbol) = match (obj, selected_symbol) {
56+
let symbol = match (obj, selected_symbol) {
5857
(Some((obj, obj_diff)), Some(SelectedSymbol::Symbol(symbol_ref))) => {
5958
let symbol = &obj.symbols[symbol_ref];
60-
(
61-
symbol.section.map(|section_idx| {
62-
(&obj.sections[section_idx], &obj_diff.sections[section_idx], section_idx)
63-
}),
64-
Some((symbol, &obj_diff.symbols[symbol_ref], symbol_ref)),
65-
)
59+
Some((symbol, &obj_diff.symbols[symbol_ref], symbol_ref))
6660
}
67-
_ => (None, None),
61+
_ => None,
6862
};
69-
Self { status, obj, section, symbol }
63+
Self { status, obj, symbol }
7064
}
7165

7266
#[inline]
73-
pub fn has_symbol(&self) -> bool { self.section.is_some() || self.symbol.is_some() }
67+
pub fn has_symbol(&self) -> bool { self.symbol.is_some() }
7468

7569
#[inline]
76-
pub fn id(&self) -> Option<&str> {
77-
self.symbol
78-
.map(|(symbol, _, _)| symbol.name.as_str())
79-
.or_else(|| self.section.map(|(section, _, _)| section.name.as_str()))
80-
}
70+
pub fn id(&self) -> Option<&str> { self.symbol.map(|(symbol, _, _)| symbol.name.as_str()) }
8171
}
8272

8373
#[must_use]
@@ -122,10 +112,7 @@ pub fn diff_view_ui(
122112
{
123113
navigation.right_symbol = Some(target_symbol_ref);
124114
}
125-
} else if navigation.left_symbol.is_some()
126-
&& left_ctx.obj.is_some()
127-
&& left_ctx.section.is_none()
128-
{
115+
} else if navigation.left_symbol.is_some() && left_ctx.obj.is_some() {
129116
// Clear selection if symbol goes missing
130117
navigation.left_symbol = None;
131118
}
@@ -136,10 +123,7 @@ pub fn diff_view_ui(
136123
{
137124
navigation.left_symbol = Some(target_symbol_ref);
138125
}
139-
} else if navigation.right_symbol.is_some()
140-
&& right_ctx.obj.is_some()
141-
&& right_ctx.section.is_none()
142-
{
126+
} else if navigation.right_symbol.is_some() && right_ctx.obj.is_some() {
143127
// Clear selection if symbol goes missing
144128
navigation.right_symbol = None;
145129
}
@@ -214,12 +198,6 @@ pub fn diff_view_ui(
214198
{
215199
ret = Some(action);
216200
}
217-
} else if let Some((section, _, _)) = left_ctx.section {
218-
ui.label(
219-
RichText::new(section.name.clone())
220-
.font(appearance.code_font.clone())
221-
.color(appearance.highlight_color),
222-
);
223201
} else if right_ctx.has_symbol() {
224202
ui.label(
225203
RichText::new("Choose target symbol")
@@ -352,12 +330,6 @@ pub fn diff_view_ui(
352330
{
353331
ret = Some(action);
354332
}
355-
} else if let Some((section, _, _)) = right_ctx.section {
356-
ui.label(
357-
RichText::new(section.name.clone())
358-
.font(appearance.code_font.clone())
359-
.color(appearance.highlight_color),
360-
);
361333
} else if left_ctx.has_symbol() {
362334
ui.label(
363335
RichText::new("Choose base symbol")
@@ -707,31 +679,6 @@ fn diff_col_ui(
707679
},
708680
);
709681
}
710-
} else if let Some((_section, section_diff, _section_idx)) = ctx.section {
711-
// Unused code for diffing an entire data section.
712-
hotkeys::check_scroll_hotkeys(ui, false);
713-
let total_bytes =
714-
section_diff.data_diff.iter().fold(0usize, |accum, item| accum + item.len);
715-
if total_bytes == 0 {
716-
return ret;
717-
}
718-
let total_rows = (total_bytes - 1) / BYTES_PER_ROW + 1;
719-
let address = 0;
720-
let diffs = split_diffs(&section_diff.data_diff, &section_diff.reloc_diff, address);
721-
render_table(
722-
ui,
723-
available_width / 2.0,
724-
1,
725-
appearance.code_font.size,
726-
total_rows,
727-
|row, _column| {
728-
let i = row.index();
729-
let address = i * BYTES_PER_ROW;
730-
row.col(|ui| {
731-
data_row_ui(ui, Some(obj), address, &diffs[i], appearance, column);
732-
});
733-
},
734-
);
735682
} else if let Some((_other_symbol, _other_symbol_diff, other_symbol_idx)) = other_ctx.symbol
736683
{
737684
if let Some(action) = symbol_list_ui(

0 commit comments

Comments
 (0)