Skip to content

Commit

Permalink
Merge pull request #38 from lucab/ups/globwalker-next-path-ref
Browse files Browse the repository at this point in the history
globwalker: avoid spurious allocations in iterator
  • Loading branch information
Gilnaa authored Jan 6, 2024
2 parents 96bd5ef + 8528c5a commit 7c4465b
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,14 +378,10 @@ impl Iterator for GlobWalker {
// able to recognize the file name.
// `unwrap` here is safe, since walkdir returns the files with relation
// to the given base-dir.
let path = e
.path()
.strip_prefix(self.ignore.path())
.unwrap()
.to_owned();
let path = e.path().strip_prefix(self.ignore.path()).unwrap();

// The path might be empty after stripping if the current base-directory is matched.
if let Some("") = path.to_str() {
if path.as_os_str().is_empty() {
continue 'skipper;
}

Expand Down

0 comments on commit 7c4465b

Please sign in to comment.