Skip to content

Commit

Permalink
feat!: reduce checking in loop
Browse files Browse the repository at this point in the history
  • Loading branch information
brglng committed Aug 9, 2024
1 parent e330fd3 commit d8c03ae
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,36 @@ fn breadth_first_traverse(prog: &str, roots: Vec<String>, allow_hidden: bool, fo
q.push(PathBuf::from("."))?;
} else {
for root in roots {
q.push(PathBuf::from(root))?;
}
}

loop {
let path = q.pop()?;
if !follow_links && path.is_symlink() {
continue;
}
if path != dotdir && path != dotdotdir {
if let Some(file_name) = path.file_name() {
if let Some(file_name) = file_name.to_str() {
if !allow_hidden {
if let Some(first_char) = file_name.chars().next() {
if first_char == '.' {
continue;
let path = PathBuf::from(root);
if !follow_links && path.is_symlink() {
continue;
}
if path != dotdir && path != dotdotdir {
if let Some(file_name) = path.file_name() {
if let Some(file_name) = file_name.to_str() {
if !allow_hidden {
if let Some(first_char) = file_name.chars().next() {
if first_char == '.' {
continue;
}
}
}
}
if ignores.get(file_name).is_some() {
continue;
if ignores.get(file_name).is_some() {
continue;
}
} else {
eprintln!("{}: {}: cannot read filename", prog, path.display())
}
} else {
eprintln!("{}: {}: cannot read filename", prog, path.display())
unreachable!("path ends with \"..\", which should not happen");
}
} else {
unreachable!("path ends with \"..\", which should not happen");
}
q.push(path)?;
}
}

loop {
let path = q.pop()?;
let entries = fs::read_dir(&path);
if let Ok(entries) = entries {
for entry in entries {
Expand Down

0 comments on commit d8c03ae

Please sign in to comment.