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