From be8c8ce23d090269f52124630b1b0b4d6034052e Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Tue, 16 Apr 2024 08:21:27 -0700 Subject: [PATCH 1/2] gnulib-tool.py: Make data structures more clear. * pygnulib/GLModuleSystem.py (GLModuleTable.__init__): Use a set to represent the unconditional modules instead of a dictionary. Remove redundant comments. (GLModuleTable.addUnconditional): Add the module to a set instead of using it as a key to the dictionary. --- ChangeLog | 9 +++++++++ pygnulib/GLModuleSystem.py | 16 ++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8418f71093..bb91326403 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2024-04-16 Collin Funk + + gnulib-tool.py: Make data structures more clear. + * pygnulib/GLModuleSystem.py (GLModuleTable.__init__): Use a set to + represent the unconditional modules instead of a dictionary. Remove + redundant comments. + (GLModuleTable.addUnconditional): Add the module to a set instead of + using it as a key to the dictionary. + 2024-04-15 Collin Funk gnulib-tool.py: Optimize directory creation. diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py index 82b3c2f6e5..11f8934026 100644 --- a/pygnulib/GLModuleSystem.py +++ b/pygnulib/GLModuleSystem.py @@ -727,13 +727,13 @@ def __init__(self, config: GLConfig, inc_all_direct_tests: bool, inc_all_indirec 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() # Dependencies - self.conditionals = dict() # Conditional modules - self.unconditionals = dict() # Unconditional modules - self.base_modules = [] # Base modules - self.main_modules = [] # Main modules - self.tests_modules = [] # Tests modules - self.final_modules = [] # Final modules + self.dependers = dict() + self.conditionals = dict() + self.unconditionals = set() + self.base_modules = [] + self.main_modules = [] + self.tests_modules = [] + self.final_modules = [] if type(config) is not GLConfig: raise TypeError('config must be a GLConfig, not %s' % type(config).__name__) @@ -781,7 +781,7 @@ def addUnconditional(self, module: GLModule) -> None: if type(module) is not GLModule: raise TypeError('module must be a GLModule, not %s' % type(module).__name__) - self.unconditionals[str(module)] = True + self.unconditionals.add(str(module)) if str(module) in self.dependers: self.dependers.pop(str(module)) -- 2.44.0