Skip to content

Commit

Permalink
Merge pull request datalad#7655 from yarikoptic/opt-use-set
Browse files Browse the repository at this point in the history
OPT: use set O(log(n)) instead of list O(n) for checking if modified in _check_files
  • Loading branch information
yarikoptic authored Sep 10, 2024
2 parents 6bd490e + 5da7e70 commit f71ff4f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelog.d/pr-7655.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### 🏎 Performance

- OPT: use set O(log(n)) instead of list O(n) for checking if modified in _check_files. [PR #7655](https://github.com/datalad/datalad/pull/7655) (by [@yarikoptic](https://github.com/yarikoptic))
5 changes: 3 additions & 2 deletions datalad/support/annexrepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1997,10 +1997,11 @@ def _check_files(self, fn, files, batch):
# ATTN: test_AnnexRepo_file_has_content has a failure before Git
# v2.13 (tested back to v2.9) because this diff call unexpectedly
# reports a type change as modified.
modified = [
modified = {
f for f in self.call_git_items_(
['diff', '--name-only', '-z'], sep='\0')
if f] if pointers else []
if f
} if pointers else set()
annex_res = fn(files, normalize_paths=False, batch=batch)
return [bool(annex_res.get(f) and
not (pointers and normpath(f) in modified))
Expand Down

0 comments on commit f71ff4f

Please sign in to comment.