Commit 95f67ad
Optimize supplement file lookup with direct tree traversal (#80)
Replace O(n) whole-tree iteration with O(1) subtree lookup when finding
supplement files (lockfiles) in the same directory as a manifest.
Before: tree.Files().ForEach() iterated every file in the repository,
then filtered by directory path - O(total files in repo) per manifest.
After: tree.Tree(dir) navigates directly to the target directory, then
iterates only its direct entries - O(files in directory) per manifest.
Performance improvement on a repository with 8619 commits:
- Before: 5:20 (320 seconds)
- After: 12 seconds
- Speedup: ~26x
Also fixes a subtle bug where filepath.Dir() was used (platform-dependent
path separators) instead of explicit "/" (git's path convention), and
removes mutation of the captured `dir` variable inside the ForEach closure.
Co-authored-by: Claude Opus 4.5 <[email protected]>1 parent 84cfd3c commit 95f67ad
1 file changed
+30
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
578 | 578 | | |
579 | 579 | | |
580 | 580 | | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
585 | 591 | | |
586 | | - | |
587 | | - | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
588 | 599 | | |
589 | | - | |
590 | | - | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
591 | 607 | | |
592 | | - | |
593 | | - | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
594 | 611 | | |
595 | 612 | | |
596 | | - | |
| 613 | + | |
597 | 614 | | |
598 | | - | |
| 615 | + | |
599 | 616 | | |
600 | 617 | | |
601 | 618 | | |
602 | 619 | | |
603 | 620 | | |
604 | 621 | | |
605 | 622 | | |
606 | | - | |
607 | | - | |
| 623 | + | |
608 | 624 | | |
609 | 625 | | |
610 | 626 | | |
| |||
0 commit comments