From 69fc1953c668afcb3c6545c7c4eb8bf7237aa3d0 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 19 Jul 2020 14:22:07 +0900 Subject: [PATCH] Close #7840: i18n: Optimize the dependencies check on bootstrap Replace a nested-loop comparison by hash-search to improve the performance of dependencies checks on bootstrap. --- CHANGES | 1 + sphinx/environment/__init__.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 36e5cc77b4b..fa8ee997e96 100644 --- a/CHANGES +++ b/CHANGES @@ -26,6 +26,7 @@ Features added * #7745: html: inventory is broken if the docname contains a space * #7902: html theme: Add a new option :confval:`globaltoc_maxdepth` to control the behavior of globaltoc in sidebar +* #7840: i18n: Optimize the dependencies check on bootstrap * #7052: add ``:noindexentry:`` to the Python, C, C++, and Javascript domains. Update the documentation to better reflect the relationship between this option and the ``:noindex:`` option. diff --git a/sphinx/environment/__init__.py b/sphinx/environment/__init__.py index 1e58542bba2..cf3364494b7 100644 --- a/sphinx/environment/__init__.py +++ b/sphinx/environment/__init__.py @@ -387,11 +387,11 @@ def find_files(self, config: Config, builder: "Builder") -> None: # add catalog mo file dependency repo = CatalogRepository(self.srcdir, self.config.locale_dirs, self.config.language, self.config.source_encoding) + mo_paths = {c.domain: c.mo_path for c in repo.catalogs} for docname in self.found_docs: domain = docname_to_domain(docname, self.config.gettext_compact) - for catalog in repo.catalogs: - if catalog.domain == domain: - self.dependencies[docname].add(catalog.mo_path) + if domain in mo_paths: + self.dependencies[docname].add(mo_paths[domain]) except OSError as exc: raise DocumentError(__('Failed to scan documents in %s: %r') % (self.srcdir, exc)) from exc