Bruno Haible <br...@clisp.org> writes: >> The lists there seem small enough that I doubt it matters too much. > > Bad excuse :) You haven't seen this module yet: > https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=blob;f=gnulib-local/modules/libxml;h=dc6404c59362e5d17885a211a61a4eed99da6642;hb=HEAD#l130
Hahaha, I concede my point then. :) This comment is interesting: # We need NO_EXPENSIVE_WARN_CFLAGS, because with gcc 13, the compilation of # libxml/parser.c requires 1.9 GB of RAM with -fanalyzer, as opposed to # 0.09 GB of RAM with -fno-analyzer. I noticed that -fanalyzer is slow on files with many lines (e.g. vasnprintf.c, many Emacs sources) but I never looked into memory usage. >> Perhaps a patch like this is a better fix then just wrapping the call in >> set() there: > > Although it would work to make _extract_lib_SOURCES return a set (since > for both callers, the order of the result is irrelevant), it is more > maintainable to let _extract_lib_SOURCES return a list and let each caller > decide whether they need a set(...) conversion or not. This way, if a > third caller is added in the future, you don't need to undo the optimization > in _extract_lib_SOURCES. Good point. I've pushed this patch adding a set() around that one call. Collin
>From c1cdc5ef8ef8b22d46bf55d8cb992f0b75532b46 Mon Sep 17 00:00:00 2001 From: Collin Funk <collin.fu...@gmail.com> Date: Mon, 3 Jun 2024 04:57:14 -0700 Subject: [PATCH] gnulib-tool.py: Use a set to optimize. * pygnulib/GLModuleSystem.py (GLModule.getAutomakeSnippet_Unconditional): Call set() on the result of _extract_lib_SOURCES() to ensure computing the difference between another set is O(n). --- ChangeLog | 8 ++++++++ pygnulib/GLModuleSystem.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 40238433eb..3e1e553dc4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-06-03 Collin Funk <collin.fu...@gmail.com> + + gnulib-tool.py: Use a set to optimize. + * pygnulib/GLModuleSystem.py + (GLModule.getAutomakeSnippet_Unconditional): Call set() on the result of + _extract_lib_SOURCES() to ensure computing the difference between + another set is O(n). + 2024-06-03 Bruno Haible <br...@clisp.org> pthread-* tests, regex tests: Prepare for use of 'alarm'. diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py index 5d67c5b6df..02dacfcf9f 100644 --- a/pygnulib/GLModuleSystem.py +++ b/pygnulib/GLModuleSystem.py @@ -587,7 +587,7 @@ def getAutomakeSnippet_Unconditional(self) -> str: snippet = self.getAutomakeSnippet_Conditional() snippet = combine_lines(snippet) # Get all the file names from 'lib_SOURCES += ...'. - mentioned_files = _extract_lib_SOURCES(snippet) + mentioned_files = set(_extract_lib_SOURCES(snippet)) all_files = self.getFiles() lib_files = filter_filelist('\n', all_files, 'lib/', '', 'lib/', '') -- 2.45.1