Skip to content

Commit

Permalink
Just use Vec
Browse files Browse the repository at this point in the history
  • Loading branch information
kimono-koans committed May 9, 2023
1 parent b5aff29 commit 83cd8f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
7 changes: 3 additions & 4 deletions src/exec/deleted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// For the full copyright and license information, please view the LICENSE file
// that was distributed with this source code.

use std::collections::LinkedList;
use std::path::{Path, PathBuf};

use rayon::Scope;
Expand Down Expand Up @@ -155,14 +154,14 @@ impl RecurseBehindDeletedDir {
from_requested_dir,
skim_tx,
) {
Ok(res) if !res.vec_dirs.is_empty() => LinkedList::from([res]),
Ok(res) if !res.vec_dirs.is_empty() => Vec::from([res]),
_ => return Ok(()),
}
}
None => return Err(HttmError::new("Not a valid directory name!").into()),
};

while let Some(item) = queue.pop_back() {
while let Some(item) = queue.pop() {
item.vec_dirs
.into_iter()
.take_while(|_| {
Expand All @@ -183,7 +182,7 @@ impl RecurseBehindDeletedDir {
.try_for_each(|res| {
res.map(|item| {
if !item.vec_dirs.is_empty() {
queue.push_back(item)
queue.push(item)
}
})
})?
Expand Down
9 changes: 3 additions & 6 deletions src/exec/recursive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// For the full copyright and license information, please view the LICENSE file
// that was distributed with this source code.

use std::collections::LinkedList;
use std::ops::Deref;
use std::{fs::read_dir, path::Path, sync::Arc};

Expand Down Expand Up @@ -91,15 +90,13 @@ impl RecursiveMainLoop {
// runs once for non-recursive but also "primes the pump"
// for recursive to have items available, also only place an
// error can stop execution
let mut queue: LinkedList<BasicDirEntryInfo> =
Self::enter_directory(requested_dir, opt_deleted_scope, skim_tx, hangup_rx)?
.into_iter()
.collect();
let mut queue: Vec<BasicDirEntryInfo> =
Self::enter_directory(requested_dir, opt_deleted_scope, skim_tx, hangup_rx)?;

if GLOBAL_CONFIG.opt_recursive {
// condition kills iter when user has made a selection
// pop_back makes this a LIFO queue which is supposedly better for caches
while let Some(item) = queue.pop_back() {
while let Some(item) = queue.pop() {
// check -- should deleted threads keep working?
// exit/error on disconnected channel, which closes
// at end of browse scope
Expand Down

0 comments on commit 83cd8f1

Please sign in to comment.