diff --git a/crates/voelin-core/src/book.rs b/crates/voelin-core/src/book.rs index 8d8e23b..00db757 100644 --- a/crates/voelin-core/src/book.rs +++ b/crates/voelin-core/src/book.rs @@ -533,9 +533,8 @@ mod tests { p.channel_groups.insert(id, group(id, &mut n)); } // Channels: a tree whose siblings follow each other. - let mut next_id = 1; let mut parents = vec![0u64]; - for _ in 0..(3 + n.below(8)) { + for id in 1..=(3 + n.below(8)) { let parent = parents[n.below(parents.len() as u64) as usize]; let order = p .channels @@ -544,8 +543,6 @@ mod tests { .map(|c| c.id) .next_back() .unwrap_or(0); - let id = next_id; - next_id += 1; parents.push(id); p.channels.insert( id, diff --git a/crates/voelin-core/src/ts_session/entities.rs b/crates/voelin-core/src/ts_session/entities.rs index 91e0d5e..3e2681b 100644 --- a/crates/voelin-core/src/ts_session/entities.rs +++ b/crates/voelin-core/src/ts_session/entities.rs @@ -154,16 +154,13 @@ fn positions(channels: &BTreeMap) -> HashMap = HashSet::new(); let mut next = 0; let mut above = 0; - loop { - // The sibling whose `order` is the one placed last (lowest id first, - // so that two claiming the same place do not depend on map order). - let Some(channel) = siblings - .iter() - .filter(|c| c.order == above && !placed.contains(&c.id)) - .min_by_key(|c| c.id) - else { - break; - }; + // The sibling whose `order` is the one placed last (lowest id first, so + // that two claiming the same place do not depend on map order). + while let Some(channel) = siblings + .iter() + .filter(|c| c.order == above && !placed.contains(&c.id)) + .min_by_key(|c| c.id) + { positions.insert(channel.id, next * 1024); placed.insert(channel.id); above = channel.id;