Use more efficient sum tree traversals for removal and improve ergonomics with iter_from

co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
Mikayla Maki 2023-05-11 16:06:25 -07:00
parent 72655fc41d
commit d538994c7f
No known key found for this signature in database
2 changed files with 84 additions and 41 deletions

View file

@ -185,7 +185,8 @@ impl RepositoryEntry {
.relativize(snapshot, path)
.and_then(|repo_path| {
self.worktree_statuses
.get_from_while(&repo_path, |repo_path, key, _| key.starts_with(repo_path))
.iter_from(&repo_path)
.take_while(|(key, _)| key.starts_with(&repo_path))
.map(|(_, status)| status)
// Short circut once we've found the highest level
.take_until(|status| status == &&GitFileStatus::Conflict)
@ -3022,7 +3023,7 @@ impl BackgroundScanner {
snapshot.repository_entries.update(&work_dir, |entry| {
entry
.worktree_statuses
.remove_from_while(&repo_path, |stored_path, _| {
.remove_by(&repo_path, |stored_path, _| {
stored_path.starts_with(&repo_path)
})
});