Skip to content

Commit 485b259

Browse files
committed
Apply clippy suggestion
1 parent d8fdfaa commit 485b259

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

Diff for: objdiff-core/src/arch/x86.rs

+23-20
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use alloc::{boxed::Box, format, string::String, vec::Vec};
2+
use core::cmp::Ordering;
23

34
use anyhow::{Context, Result, anyhow, bail};
45
use iced_x86::{
@@ -100,28 +101,30 @@ impl Arch for ArchX86 {
100101
'outer: while decoder.can_decode() {
101102
let address = decoder.ip();
102103
while let Some(reloc) = reloc_iter.peek() {
103-
if reloc.address < address {
104-
reloc_iter.next();
105-
} else if reloc.address == address {
106-
// If the instruction starts at a relocation, it's inline data
107-
let size = self.reloc_size(reloc.flags).with_context(|| {
108-
format!("Unsupported inline x86 relocation {:?}", reloc.flags)
109-
})?;
110-
if decoder.set_position(decoder.position() + size).is_ok() {
111-
decoder.set_ip(address + size as u64);
112-
out.push(ScannedInstruction {
113-
ins_ref: InstructionRef {
114-
address,
115-
size: size as u8,
116-
opcode: DATA_OPCODE,
117-
},
118-
branch_dest: None,
119-
});
104+
match reloc.address.cmp(&address) {
105+
Ordering::Less => {
120106
reloc_iter.next();
121-
continue 'outer;
122107
}
123-
} else {
124-
break;
108+
Ordering::Equal => {
109+
// If the instruction starts at a relocation, it's inline data
110+
let size = self.reloc_size(reloc.flags).with_context(|| {
111+
format!("Unsupported inline x86 relocation {:?}", reloc.flags)
112+
})?;
113+
if decoder.set_position(decoder.position() + size).is_ok() {
114+
decoder.set_ip(address + size as u64);
115+
out.push(ScannedInstruction {
116+
ins_ref: InstructionRef {
117+
address,
118+
size: size as u8,
119+
opcode: DATA_OPCODE,
120+
},
121+
branch_dest: None,
122+
});
123+
reloc_iter.next();
124+
continue 'outer;
125+
}
126+
}
127+
Ordering::Greater => break,
125128
}
126129
}
127130
decoder.decode_out(&mut instruction);

0 commit comments

Comments
 (0)