]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
gnulib-tool.py: Simplify data structures for dependencies.
authorCollin Funk <collin.funk1@gmail.com>
Fri, 19 Apr 2024 18:32:44 +0000 (11:32 -0700)
committerBruno Haible <bruno@clisp.org>
Fri, 19 Apr 2024 21:14:32 +0000 (23:14 +0200)
* pygnulib/GLModuleSystem.py (GLModuleTable.__init__): Use a defaultdict
for dependers to remove the base initialization case.
(GLModuleTable.addConditional): Use a set to disallow duplicates instead
of performing list lookups.

ChangeLog
pygnulib/GLModuleSystem.py

index e84856cc05aae3fa9dfc83bc75217ac49ab59073..d907a52c53b459a07948f52ec6fb945d8103fc39 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-04-19  Collin Funk  <collin.funk1@gmail.com>
+
+       gnulib-tool.py: Simplify data structures for dependencies.
+       * pygnulib/GLModuleSystem.py (GLModuleTable.__init__): Use a defaultdict
+       for dependers to remove the base initialization case.
+       (GLModuleTable.addConditional): Use a set to disallow duplicates instead
+       of performing list lookups.
+
 2024-04-19  Bruno Haible  <bruno@clisp.org>
 
        gnulib-tool.py: Simplify running some commands in a given directory.
index 112a6bc0e649b24e4dd0684dae3d6e43a313f7ea..ce1fad110cb937ed08fd6f5c774e2e93f7bbd334 100644 (file)
@@ -23,6 +23,7 @@ import re
 import sys
 import hashlib
 import subprocess as sp
+from collections import defaultdict
 from . import constants
 from .GLError import GLError
 from .GLConfig import GLConfig
@@ -721,7 +722,7 @@ class GLModuleTable:
           returns the condition when B should be enabled as a dependency of A,
           once the m4 code for A has been executed.
         '''
-        self.dependers = dict()
+        self.dependers = defaultdict(set)
         self.conditionals = dict()
         self.unconditionals = set()
         self.base_modules = []
@@ -763,10 +764,7 @@ class GLModuleTable:
                             % type(condition).__name__)
         if str(module) not in self.unconditionals:
             # No unconditional dependency to the given module is known at this point.
-            if str(module) not in self.dependers:
-                self.dependers[str(module)] = []
-            if str(parent) not in self.dependers[str(module)]:
-                self.dependers[str(module)].append(str(parent))
+            self.dependers[str(module)].add(str(parent))
             key = '%s---%s' % (str(parent), str(module))
             self.conditionals[key] = condition