Hi Bruno,
On 4/9/24 5:48 AM, Bruno Haible wrote:
> OK, fine with me: there are no accessors for inc_all_direct_tests and
> inc_all_indirect_tests either.
Patch 0001 removes the unused functions. Patch 0002 turns avoidlist
into a set.
Collin
From eb0dcffdf06a59f2d71010ce2030ed2d583f6500 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Tue, 9 Apr 2024 08:55:02 -0700
Subject: [PATCH 1/2] gnulib-tool.py: Remove unused setter and getter
functions.
* pygnulib/GLModuleSystem.py (GLModuleTable.getAvoids)
(GLModuleTable.setAvoids): Remove these unused functions.
---
ChangeLog | 6 ++++++
pygnulib/GLModuleSystem.py | 11 -----------
2 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b08142ab38..57dbc6f329 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-04-09 Collin Funk <collin.fu...@gmail.com>
+
+ gnulib-tool.py: Remove unused setter and getter functions.
+ * pygnulib/GLModuleSystem.py (GLModuleTable.getAvoids)
+ (GLModuleTable.setAvoids): Remove these unused functions.
+
2024-04-09 Collin Funk <collin.fu...@gmail.com>
gnulib-tool.py: Simplify use of GLModuleTable accessors.
diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py
index 3ba9b7f473..3669ac9754 100644
--- a/pygnulib/GLModuleSystem.py
+++ b/pygnulib/GLModuleSystem.py
@@ -1057,17 +1057,6 @@ class GLModuleTable:
result = tuple([main_filelist, tests_filelist])
return result
- def getAvoids(self) -> list[GLModule]:
- '''Return list of avoids.'''
- return list(self.avoids)
-
- def setAvoids(self, modules: list[GLModule]) -> None:
- '''Specify list of avoids.'''
- for module in modules:
- if type(module) is not GLModule:
- raise TypeError('each module must be a GLModule instance')
- self.avoids = sorted(set(modules))
-
def getBaseModules(self) -> list[GLModule]:
'''Return list of base modules.'''
return list(self.base_modules)
--
2.44.0
From 071d8cb0ce6f23b3fc877a4f6f450420f814bb40 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Tue, 9 Apr 2024 09:11:03 -0700
Subject: [PATCH 2/2] 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 57dbc6f329..d64754cb1a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-04-09 Collin Funk <collin.fu...@gmail.com>
+
+ 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 <collin.fu...@gmail.com>
gnulib-tool.py: Remove unused setter and getter functions.
diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py
index 3669ac9754..064f6fa6e7 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() # Avoids
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.44.0