src/pxar/fuse.rs: refactor Iterator: use find() instead of position()
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
parent
b82a101c86
commit
9708b2d98c
@ -452,15 +452,11 @@ fn find_goodbye_entry(
|
|||||||
update_goodbye_cache(&mut ctx)?;
|
update_goodbye_cache(&mut ctx)?;
|
||||||
if let Some((_, gbt)) = &ctx.goodbye_cache {
|
if let Some((_, gbt)) = &ctx.goodbye_cache {
|
||||||
let mut iterator = gbt.iter();
|
let mut iterator = gbt.iter();
|
||||||
let mut position = 0;
|
|
||||||
loop {
|
loop {
|
||||||
// Search for the next position where the hash matches the one in the
|
// Search for the next goodbye entry with matching hash.
|
||||||
// goodbye table.
|
let (_item, start, end) = iterator.find(|(i, _, _)| i.hash == hash)
|
||||||
position += iterator
|
|
||||||
.position(|(e, _, _)| e.hash == hash)
|
|
||||||
.ok_or(libc::ENOENT)?;
|
.ok_or(libc::ENOENT)?;
|
||||||
|
|
||||||
let (_item, start, end) = &gbt[position];
|
|
||||||
// At this point it is not clear if the item is a directory or not, this
|
// At this point it is not clear if the item is a directory or not, this
|
||||||
// has to be decided based on the entry mode.
|
// has to be decided based on the entry mode.
|
||||||
// `Decoder`s attributes function accepts both, offsets pointing to
|
// `Decoder`s attributes function accepts both, offsets pointing to
|
||||||
@ -475,8 +471,6 @@ fn find_goodbye_entry(
|
|||||||
let child_offset = find_offset(&entry, *start, *end);
|
let child_offset = find_offset(&entry, *start, *end);
|
||||||
return Ok((child_offset, entry, attr, payload_size));
|
return Ok((child_offset, entry, attr, payload_size));
|
||||||
}
|
}
|
||||||
// Have to shift the position by one as next in iterator will be 0
|
|
||||||
position += 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user