From: Collin Funk Date: Tue, 9 Apr 2024 16:11:03 +0000 (-0700) Subject: gnulib-tool.py: Change the avoid list to a set for lookups. X-Git-Tag: v1.0~134 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=760841f16b9c29da2ff00885d0fdf3462bcfb930;p=gnulib.git gnulib-tool.py: Change the avoid list to a set for lookups. * pygnulib/GLModuleSystem.py (GLModuleSystem.__init__): Store the avoided modules in a set instead of a list. This is used only for membership checks when computing the transitive closure of the given modules, therefore prefer the O(1) average case over O(n). --- diff --git a/ChangeLog b/ChangeLog index 8a09d0668f..033eb5dc92 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-04-09 Collin Funk + + gnulib-tool.py: Change the avoid list to a set for lookups. + * pygnulib/GLModuleSystem.py (GLModuleSystem.__init__): Store the + avoided modules in a set instead of a list. This is used only for + membership checks when computing the transitive closure of the given + modules, therefore prefer the O(1) average case over O(n). + 2024-04-09 Collin Funk gnulib-tool.py: Remove unused setter and getter functions. diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py index 3669ac9754..ed96b9846c 100644 --- a/pygnulib/GLModuleSystem.py +++ b/pygnulib/GLModuleSystem.py @@ -750,11 +750,11 @@ class GLModuleTable: % type(inc_all_direct_tests).__name__) self.inc_all_direct_tests = inc_all_direct_tests self.inc_all_indirect_tests = inc_all_indirect_tests - self.avoids = [] # Avoids + self.avoids = set() for avoid in self.config.getAvoids(): module = self.modulesystem.find(avoid) if module: - self.avoids.append(module) + self.avoids.add(module) def __repr__(self) -> str: '''x.__repr__() <==> repr(x)'''