From 24af1bb4778f683be73726a3e0b47a022dd75196 Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Mon, 8 Apr 2024 01:48:41 -0700 Subject: [PATCH 5/7] gnulib-tool.py: Simplify file list construction. * pygnulib/GLModuleSystem.py (GLModuleTable.filelist): Use a set to construct the file list instead of looping through a list for each file. Sort the result to match gnulib-tool.sh. --- ChangeLog | 7 +++++++ pygnulib/GLModuleSystem.py | 7 +++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0f0aedd2d2..aaa4d63652 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2024-04-08 Collin Funk + + gnulib-tool.py: Simplify file list construction. + * pygnulib/GLModuleSystem.py (GLModuleTable.filelist): Use a set to + construct the file list instead of looping through a list for each file. + Sort the result to match gnulib-tool.sh. + 2024-04-07 Collin Funk gnulib-tool.py: Fix incomplete type hint. diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py index 761c43c2e0..1532610466 100644 --- a/pygnulib/GLModuleSystem.py +++ b/pygnulib/GLModuleSystem.py @@ -1047,7 +1047,7 @@ class GLModuleTable: def filelist(self, modules: list[GLModule]) -> list[str]: '''Determine the final file list for the given list of modules. The list of modules must already include dependencies.''' - filelist = [] + fileset = set() for module in modules: if type(module) is not GLModule: raise TypeError('each module must be a GLModule instance') @@ -1055,9 +1055,8 @@ class GLModuleTable: for module in modules ] for listing in listings: for file in listing: - if file not in filelist: - filelist += [file] - return filelist + fileset.add(file) + return sorted(fileset) def filelist_separately(self, main_modules: list[GLModule], tests_modules: list[GLModule]) -> tuple[list[str], list[str]]: -- 2.44.0