Skip to content

Commit 2b39879

Browse files
committed
fmt & clippy
1 parent 6baa8a0 commit 2b39879

1 file changed

Lines changed: 11 additions & 29 deletions

File tree

src/util/split.rs

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ fn split_extabindex(obj: &mut ObjInfo, start: SectionAddress) -> Result<()> {
246246
group_sizes[g] += 1;
247247
}
248248

249-
for g in 0..num_groups {
250-
if group_sizes[g] <= 1 {
249+
for (g, group_size) in group_sizes.into_iter().enumerate() {
250+
if group_size <= 1 {
251251
continue; // Only process multi-entry (reversed) groups
252252
}
253253

@@ -268,8 +268,7 @@ fn split_extabindex(obj: &mut ObjInfo, start: SectionAddress) -> Result<()> {
268268
.unwrap();
269269

270270
// Find the first entry in this group
271-
let first_in_group =
272-
group_ids.iter().position(|&gid| gid == g).unwrap();
271+
let first_in_group = group_ids.iter().position(|&gid| gid == g).unwrap();
273272

274273
// Walk backwards from the first entry, absorbing earlier entries
275274
// whose extab falls within [min_extab, max_extab]
@@ -301,8 +300,7 @@ fn split_extabindex(obj: &mut ObjInfo, start: SectionAddress) -> Result<()> {
301300
}
302301

303302
// Phase C: Process each group.
304-
for g in 0..num_groups {
305-
let indices = &group_entries[g];
303+
for indices in group_entries {
306304
if indices.is_empty() {
307305
continue;
308306
}
@@ -320,7 +318,7 @@ fn split_extabindex(obj: &mut ObjInfo, start: SectionAddress) -> Result<()> {
320318
// Validate all entries and collect symbol info for the group.
321319
let mut function_symbols = Vec::new();
322320
let mut extab_symbols = Vec::new();
323-
for &idx in indices {
321+
for &idx in &indices {
324322
let entry = &entries[idx];
325323
let Some((_, eti_symbol)) = obj.symbols.kind_at_section_address(
326324
entry.eti_address.section,
@@ -376,7 +374,7 @@ fn split_extabindex(obj: &mut ObjInfo, start: SectionAddress) -> Result<()> {
376374
let mut expected_unit: Option<String> = None;
377375

378376
// Check all entries for existing user-defined splits.
379-
for &idx in indices {
377+
for &idx in &indices {
380378
let entry = &entries[idx];
381379
let text_section = &obj.sections[entry.function_addr.section];
382380
for (_, split) in [
@@ -429,15 +427,10 @@ fn split_extabindex(obj: &mut ObjInfo, start: SectionAddress) -> Result<()> {
429427
.max_by_key(|&(_, &i)| entries[i].function_addr.address)
430428
.unwrap();
431429
let func_max_entry = &entries[indices[func_max_local_idx]];
432-
let func_end =
433-
func_max_entry.function_addr + func_max_entry.function_size;
430+
let func_end = func_max_entry.function_addr + func_max_entry.function_size;
434431

435432
// Create one covering split per section type.
436-
log::debug!(
437-
"Adding split for extabindex group @ {:#010X}-{:#010X}",
438-
eti_min,
439-
eti_end
440-
);
433+
log::debug!("Adding split for extabindex group @ {:#010X}-{:#010X}", eti_min, eti_end);
441434
new_splits.insert(eti_min, ObjSplit {
442435
unit: unit.clone(),
443436
end: eti_end.address,
@@ -447,11 +440,7 @@ fn split_extabindex(obj: &mut ObjInfo, start: SectionAddress) -> Result<()> {
447440
skip: false,
448441
rename: None,
449442
});
450-
log::debug!(
451-
"Adding split for extab group @ {:#010X}-{:#010X}",
452-
extab_min,
453-
extab_end
454-
);
443+
log::debug!("Adding split for extab group @ {:#010X}-{:#010X}", extab_min, extab_end);
455444
new_splits.insert(extab_min, ObjSplit {
456445
unit: unit.clone(),
457446
end: extab_end.address,
@@ -461,11 +450,7 @@ fn split_extabindex(obj: &mut ObjInfo, start: SectionAddress) -> Result<()> {
461450
skip: false,
462451
rename: None,
463452
});
464-
log::debug!(
465-
"Adding split for function group @ {:#010X}-{:#010X}",
466-
func_min,
467-
func_end
468-
);
453+
log::debug!("Adding split for function group @ {:#010X}-{:#010X}", func_min, func_end);
469454
new_splits.insert(func_min, ObjSplit {
470455
unit,
471456
end: func_end.address,
@@ -519,10 +504,7 @@ fn split_extabindex(obj: &mut ObjInfo, start: SectionAddress) -> Result<()> {
519504
}
520505
}
521506

522-
if extabindex_split.is_none()
523-
|| extab_split.is_none()
524-
|| function_split.is_none()
525-
{
507+
if extabindex_split.is_none() || extab_split.is_none() || function_split.is_none() {
526508
let unit = match expected_unit {
527509
Some(unit) => unit,
528510
None => auto_unit_name(obj, function_symbol, &new_splits)?,

0 commit comments

Comments
 (0)