From 4c33732c982e72764c305b3d869393e1da17b2ae Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Mon, 16 Dec 2024 23:55:47 -0600 Subject: [PATCH] Cache distro_series so it's not fetched multiple times --- src/source_package_publishing_history.cpp | 2 ++ src/source_package_publishing_history.h | 1 + 2 files changed, 3 insertions(+) diff --git a/src/source_package_publishing_history.cpp b/src/source_package_publishing_history.cpp index b71af24..e3ac952 100644 --- a/src/source_package_publishing_history.cpp +++ b/src/source_package_publishing_history.cpp @@ -27,6 +27,7 @@ source_package_publishing_history::source_package_publishing_history() lp(nullptr), distro_series([this]() -> std::optional { if (distro_series_link.empty()) return std::nullopt; + if (_distro_series) return _distro_series; auto response = lp ? lp->api_get(distro_series_link) : std::nullopt; if (!response) return std::nullopt; @@ -36,6 +37,7 @@ source_package_publishing_history::source_package_publishing_history() if (ds) { ds->set_lp(lp); + _distro_series = ds; return ds; } diff --git a/src/source_package_publishing_history.h b/src/source_package_publishing_history.h index 6a1ae9d..9b944ea 100644 --- a/src/source_package_publishing_history.h +++ b/src/source_package_publishing_history.h @@ -57,6 +57,7 @@ public: private: launchpad* lp; + std::optional _distro_series = std::nullopt; }; #endif // SOURCE_PACKAGE_PUBLISHING_HISTORY