From cd51f57405536ee84b164a510b626dd965b3c3a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= Date: Tue, 1 Oct 2024 07:12:39 -0400 Subject: [PATCH] Set `POOL_FLAG_ADDFILEPROVIDESFILTERED` only when not loading filelists It is set in `dnf_sack_load_repo` which means its done for each repo, this is not needed, it would be sufficient to set the flag only once. However there is a ready access to whether filelists are loaded and the call `pool_set_flag` is very cheap. Any alternatives I could see would probably require extending the API which seems unnecessary. --- libdnf/dnf-sack.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libdnf/dnf-sack.cpp b/libdnf/dnf-sack.cpp index e95009fb2..2ce16613b 100644 --- a/libdnf/dnf-sack.cpp +++ b/libdnf/dnf-sack.cpp @@ -186,12 +186,6 @@ dnf_sack_init(DnfSack *sack) priv->pool = pool_create(); pool_set_flag(priv->pool, POOL_FLAG_WHATPROVIDESWITHDISABLED, 1); - // Configures the pool_addfileprovides_queue() method to only add files from primary.xml. - // This ensures the method works correctly even if filelist.xml metadata are not loaded. - // At the same time when filelist.xml are loaded libsolv is able to search them for required - // files if needed. - pool_set_flag(priv->pool, POOL_FLAG_ADDFILEPROVIDESFILTERED, 1); - priv->running_kernel_id = -1; priv->running_kernel_fn = running_kernel; priv->considered_uptodate = TRUE; @@ -1890,6 +1884,13 @@ dnf_sack_load_repo(DnfSack *sack, HyRepo repo, int flags, GError **error) try HY_EXT_FILENAMES, error)) return FALSE; } + } else { + // Configures the pool_addfileprovides_queue() method to only add files from primary.xml. + // This ensures the method works correctly even if filelist.xml metadata are not loaded. + // When searching for file provides outside of primary.xml this flag incurs a big performance + // hit because libsolv has to go through all the files for each file provide therefore don't + // set it if filelists are loaded. + pool_set_flag(priv->pool, POOL_FLAG_ADDFILEPROVIDESFILTERED, 1); } if (flags & DNF_SACK_LOAD_FLAG_USE_OTHER) { retval = load_ext(sack, repo, _HY_REPODATA_OTHER,