mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-17 13:14:26 +00:00
cleanup: use while let Some(...)
instead of checking before popping
This commit is contained in:
parent
00a8abcdbb
commit
5893b52fd1
@ -87,8 +87,7 @@ where
|
||||
|
||||
for start_node in start_nodes {
|
||||
let mut stack = vec![(start_node, false)];
|
||||
while !stack.is_empty() {
|
||||
let (node, neighbors_visited) = stack.pop().unwrap();
|
||||
while let Some((node, neighbors_visited)) = stack.pop() {
|
||||
let id = id_fn(&node);
|
||||
if emitted.contains(&id) {
|
||||
continue;
|
||||
|
@ -763,8 +763,7 @@ impl<'a> CompositeIndex<'a> {
|
||||
let ancestor_generation = self.entry_by_pos(ancestor_pos).generation_number();
|
||||
let mut work = vec![descendant_pos];
|
||||
let mut visited = HashSet::new();
|
||||
while !work.is_empty() {
|
||||
let descendant_pos = work.pop().unwrap();
|
||||
while let Some(descendant_pos) = work.pop() {
|
||||
let descendant_entry = self.entry_by_pos(descendant_pos);
|
||||
if descendant_pos == ancestor_pos {
|
||||
return true;
|
||||
@ -889,8 +888,7 @@ impl<'a> CompositeIndex<'a> {
|
||||
// set of candidates. Stop walking when we have gone past the minimum
|
||||
// candidate generation.
|
||||
let mut visited = HashSet::new();
|
||||
while !work.is_empty() {
|
||||
let item = work.pop().unwrap().0;
|
||||
while let Some(IndexEntryByGeneration(item)) = work.pop() {
|
||||
if !visited.insert(item.pos) {
|
||||
continue;
|
||||
}
|
||||
@ -1017,8 +1015,7 @@ impl<'a> Iterator for RevWalk<'a> {
|
||||
type Item = IndexEntry<'a>;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
while !self.wanted_boundary_set.is_empty() {
|
||||
let item = self.items.pop().unwrap();
|
||||
while let Some(item) = self.items.pop() {
|
||||
if item.wanted {
|
||||
self.wanted_boundary_set.remove(&item.entry.0.pos);
|
||||
if self.unwanted_boundary_set.contains(&item.entry.0.pos) {
|
||||
|
@ -187,8 +187,7 @@ fn topo_order_earlier_first(
|
||||
let mut visited = HashSet::new();
|
||||
let mut in_parent_file = HashSet::new();
|
||||
let parent_file_source = parent_file.as_ref().map(|file| file.as_ref());
|
||||
while !work.is_empty() {
|
||||
let commit = work.pop().unwrap();
|
||||
while let Some(commit) = work.pop() {
|
||||
if parent_file_source.map_or(false, |index| index.has_id(commit.id())) {
|
||||
in_parent_file.insert(commit.id().clone());
|
||||
continue;
|
||||
@ -213,8 +212,7 @@ fn topo_order_earlier_first(
|
||||
|
||||
let mut result = vec![];
|
||||
let mut visited = in_parent_file;
|
||||
while !commits.is_empty() {
|
||||
let commit = commits.pop().unwrap();
|
||||
while let Some(commit) = commits.pop() {
|
||||
let mut waiting_for_earlier_commit = false;
|
||||
for earlier in commit.parents().iter().chain(commit.predecessors().iter()) {
|
||||
if !visited.contains(earlier.id()) {
|
||||
|
@ -335,8 +335,7 @@ impl TreeState {
|
||||
)];
|
||||
let mut tree_builder = self.store.tree_builder(self.tree_id.clone());
|
||||
let mut deleted_files: HashSet<_> = self.file_states.keys().cloned().collect();
|
||||
while !work.is_empty() {
|
||||
let (dir, disk_dir, git_ignore) = work.pop().unwrap();
|
||||
while let Some((dir, disk_dir, git_ignore)) = work.pop() {
|
||||
if sparse_matcher.visit(&dir).is_nothing() {
|
||||
continue;
|
||||
}
|
||||
|
@ -864,8 +864,7 @@ fn find_all_operations(
|
||||
let mut visited = HashSet::new();
|
||||
let mut work: VecDeque<_> = op_heads_store.get_op_heads().into_iter().collect();
|
||||
let mut operations = vec![];
|
||||
while !work.is_empty() {
|
||||
let op_id = work.pop_front().unwrap();
|
||||
while let Some(op_id) = work.pop_front() {
|
||||
if visited.insert(op_id.clone()) {
|
||||
let store_operation = op_store.read_operation(&op_id).unwrap();
|
||||
work.extend(store_operation.parents.iter().cloned());
|
||||
|
Loading…
x
Reference in New Issue
Block a user