[Git][reproducible-builds/diffoscope][master] Don't duplicate file lists at each directory level. (Closes:...

Chris Lamb (@lamby) gitlab at salsa.debian.org
Thu Nov 18 19:54:20 UTC 2021



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
181dbb3f by Chris Lamb at 2021-11-18T11:53:58-08:00
Don't duplicate file lists at each directory level. (Closes: reproducible-builds/diffoscope#263, Debian:#989192)

- - - - -


1 changed file:

- diffoscope/comparators/directory.py


Changes:

=====================================
diffoscope/comparators/directory.py
=====================================
@@ -35,20 +35,6 @@ from .utils.container import Container
 logger = logging.getLogger(__name__)
 
 
-def list_files(path):
-    path = os.path.realpath(path)
-    all_files = []
-    for root, dirs, names in os.walk(path):
-        all_files.extend(
-            [os.path.join(root[len(path) + 1 :], dir) for dir in dirs]
-        )
-        all_files.extend(
-            [os.path.join(root[len(path) + 1 :], name) for name in names]
-        )
-    all_files.sort()
-    return all_files
-
-
 if os.uname()[0] == "FreeBSD":
 
     class Stat(Command):
@@ -267,6 +253,11 @@ class FilesystemDirectory(Directory):
     def compare(self, other, source=None):
         differences = []
 
+        # We don't need to recurse into subdirectories; DirectoryContainer will
+        # find them and do that for us.
+        def list_files(path):
+            return sorted(os.listdir(os.path.realpath(path)))
+
         listing_diff = Difference.from_text(
             "\n".join(list_files(self.path)),
             "\n".join(list_files(other.path)),



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/181dbb3fb61d9056a773155f344cb9846580cadb

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/181dbb3fb61d9056a773155f344cb9846580cadb
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20211118/98c05abc/attachment.htm>


More information about the rb-commits mailing list