From b25b2301e396065471c57070db251f8794a2a2a8 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Mon, 5 May 2025 01:07:47 +0100 Subject: [PATCH] Codechange: Use EnumBitSet instead of Vector to record received content types. --- src/network/core/tcp_content_type.h | 1 + src/network/network_content_gui.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/network/core/tcp_content_type.h b/src/network/core/tcp_content_type.h index edff5c896a..c61217001d 100644 --- a/src/network/core/tcp_content_type.h +++ b/src/network/core/tcp_content_type.h @@ -33,6 +33,7 @@ enum ContentType : uint8_t { CONTENT_TYPE_END, ///< Helper to mark the end of the types INVALID_CONTENT_TYPE = 0xFF, ///< Invalid/uninitialized content }; +using ContentTypes = EnumBitSet; /** Enum with all types of TCP content packets. The order MUST not be changed **/ enum PacketContentType : uint8_t { diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index 97e6cb88dc..b9f5feccd8 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -187,7 +187,7 @@ void BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(const ContentInf /** Window for showing the download status of content */ struct NetworkContentDownloadStatusWindow : public BaseNetworkContentDownloadStatusWindow { private: - std::vector receivedTypes{}; ///< Types we received so we can update their cache + ContentTypes received_types{}; ///< Types we received so we can update their cache public: /** @@ -202,7 +202,7 @@ public: void Close([[maybe_unused]] int data = 0) override { TarScanner::Modes modes{}; - for (auto ctype : this->receivedTypes) { + for (auto ctype : this->received_types) { switch (ctype) { case CONTENT_TYPE_AI: case CONTENT_TYPE_AI_LIBRARY: @@ -236,7 +236,7 @@ public: TarScanner::DoScan(modes); /* Tell all the backends about what we've downloaded */ - for (auto ctype : this->receivedTypes) { + for (auto ctype : this->received_types) { switch (ctype) { case CONTENT_TYPE_AI: case CONTENT_TYPE_AI_LIBRARY: @@ -301,7 +301,7 @@ public: void OnDownloadProgress(const ContentInfo &ci, int bytes) override { BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(ci, bytes); - include(this->receivedTypes, ci.type); + this->received_types.Set(ci.type); /* When downloading is finished change cancel in ok */ if (this->downloaded_bytes == this->total_bytes) {