From 760841f16b9c29da2ff00885d0fdf3462bcfb930 Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Tue, 9 Apr 2024 09:11:03 -0700 Subject: [PATCH] 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). --- ChangeLog | 8 ++++++++ pygnulib/GLModuleSystem.py | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) 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)''' -- 2.39.5