]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
gnulib-tool.py: Optimize directory creation.
authorCollin Funk <collin.funk1@gmail.com>
Mon, 15 Apr 2024 16:16:25 +0000 (09:16 -0700)
committerBruno Haible <bruno@clisp.org>
Mon, 15 Apr 2024 16:28:29 +0000 (18:28 +0200)
* pygnulib/GLTestDir.py (GLTestDir.execute): Use a list of possible
subdirectories and create them upfront instead of checking every file.

ChangeLog
pygnulib/GLTestDir.py

index 2ab6e41ae22e35c5bfafb75bdbf7c0d530b3fe7f..8418f710932bdc21067909626fc1b383a77c1ca4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-04-15  Collin Funk  <collin.funk1@gmail.com>
+
+       gnulib-tool.py: Optimize directory creation.
+       * pygnulib/GLTestDir.py (GLTestDir.execute): Use a list of possible
+       subdirectories and create them upfront instead of checking every file.
+
 2024-04-15  Simon Josefsson  <simon@josefsson.org>
 
        gitlog-to-changelog: Revert 2024-04-12 fix and add documentation.
index a7709a1259a547cf21abf0c5e05287a183af9a6d..b668629f4dd66d6c2c4965d9f4ea3337123fddce 100644 (file)
@@ -345,9 +345,12 @@ class GLTestDir:
         filelist = sorted(set(filelist))
 
         # Create directories.
-        directories = [os.path.dirname(file)
-                       for file in self.rewrite_files(filelist)]
+        directories = [ joinpath(self.testdir, os.path.dirname(file))
+                        for file in self.rewrite_files(filelist) ]
         directories = sorted(set(directories))
+        for directory in directories:
+            if not isdir(directory):
+                os.makedirs(directory)
 
         # Copy files or make symbolic links or hard links.
         filetable = []
@@ -358,9 +361,6 @@ class GLTestDir:
             src = row[1]
             dest = row[0]
             destpath = joinpath(self.testdir, dest)
-            dirname = os.path.dirname(destpath)
-            if not isdir(dirname):
-                os.makedirs(dirname)
             if src.startswith('tests=lib/'):
                 src = constants.substart('tests=lib/', 'lib/', src)
             lookedup, flag = self.filesystem.lookup(src)